在 jquery DataTables 加载之前,表数据加载,简短且未格式化。我研究过并发现很多人说解决方案是用 css 隐藏表格,然后用 initComplete 在 jquery 中显示它。我尝试了以下但似乎没有任何效果:
css:
#tblAccount {
visibility:hidden;
}
#tblCustomer {
visibility: hidden;
}
jquery:
$(function () {
$("[id*=tblAccount], [id *= tblCustomer]").prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": true,
"responsive": true,
"dom": 'lBfrtip',
"buttons": ['excel', 'print', 'pdfHtml5'],
"initComplete": function () {
$('#tblAccount').show().css({ visibility: "visible" });
$('#tblCustomer').show().css({ visibility: "visible" });
}
});
})
最佳答案
我认为您不需要 .show() 函数和使用 css({ visibility: "visible"}) 更改 css。
如果您开始加载在#tblAccount 和#tblCustomer 上具有“display : none”的页面,那么请保留
$('#tblAccount').show();
$('#tblCustomer').show();
在 initComplete 函数中,你应该得到你正在寻找的功能。
关于jquery - 在 jquery DataTables 加载之前,表数据加载,简短且未格式化。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53782455/