我正在使用Datatables并使用jQuery .toggle()隐藏了某些行,这基本上只是添加了一个" display:none"对于有问题的元素。我有隐藏的行,而我的表的垂直滚动不会根据可见内容和不可见内容重新计算表的长度。因此,在最后一个可见元素之后,存在空白空间,其中以前的行仍然可以滚动。
我正在寻找一种基于可见内容重新计算表滚动高度的方法。
初始化代码:
g_oTable = $('#' + tableName).DataTable({
colReorder: true
, rowId: 'alertid'
, searchHighlight: true
, stateSave: true
, stateDuration: -1
, autoWidth: false
, order: [
[0, "asc"], [5, "desc"]
]
, info: true
, scroller: true
, scrollX: false
, scrollY: ($(window).height() - 215)
, scrollCollapse: true
, deferRender: false
, rowGroup: {
enable: false,
startRender: function ( rows, group ) {
return '<span class="fa fa-chevron-right" style="margin-
left:5px;margin-right:10px;"aria-hidden="true"></span>'
+ group +' ('+rows.count()+')';
}
}
答案 0 :(得分:0)
每次切换某些行的可见性时,请尝试调用以下代码。
$.fn.dataTable
.tables( { visible: true, api: true } )
.scroller.measure();
答案 1 :(得分:0)
我找到了自己的答案。在我的初始化中,我使用了滚动条,我没有文档或推理,因为它与我的用例不兼容,但使用res = not "Zombie" in os.popen("cat /proc/`pidof %s`/status" % 'python3')
帮助我解决了这个问题。