我已使用此table。我需要第一个行 tbody
(显示列的平均数量)不应该排序,我的意思是行应该在顶部总是(below thead
),如下所示:
。我怎样才能做到这一点?我在谷歌搜索解决方案,大多数时候我发现把那行放在thead
或类似的东西上。但是,如果我试着把那一行放在那个地方,那对我来说似乎太复杂了。那么,有没有什么方法可以在该行上放置一个类并禁用该分类行上的sortng?喜欢:<tr class="average no-sort"></tr>
答案 0 :(得分:1)
我有同样的问题,在我的情况下,我这样解决了:
const firstRequest = axios.get('https://maps.googleapis.com/maps/api/geocode/json?&address=' + this.props.p1)
.then(response => this.setState({ p1Location: response.data })) }
const secondRequest = axios.get('https://maps.googleapis.com/maps/api/geocode/json?&address=' + this.props.p2)
.then(response => this.setState({ p2Location: response.data }))
const thirdRequest = axios.get('https://maps.googleapis.com/maps/api/directions/json?origin=place_id:' + this.state.p1Location.results.place_id + '&destination=place_id:' + this.state.p2Location.results.place_id + '&key=' + 'API-KEY-HIDDEN')
.then(response => this.setState({ route: response.data }))
Promise.all([firstRequest, secondRequest])
.then(() => {
return thirdRequest
})
答案 1 :(得分:0)
我在表格中创建了第二个tbody
,只需将我需要保留的所有行移到另一个tbody
中,如下所示:
initComplete: function() {
var self = this;
var api = this.api();
api.rows().eq(0).each(function(index) {
var row = api.row(index);
if (row.data()...) { // condition here
var $row_to_persist = $(row.node());
var $clone = $row_to_persist.clone();
$(self).find('tbody:last').append($clone);
$total_row.remove();
row.remove();
api.draw();
}
});
}
答案 2 :(得分:0)
同时寻找解决方案。通过在表启动后修改dom很容易,但这会破坏所有响应功能。
在完成排序和过滤后,需要一种方法将行保留在表的顶部。
答案 3 :(得分:0)