jquery - 在 jquery DataTables 加载之前,表数据加载,简短且未格式化。

标签 jquery css datatable

在 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/

相关文章:

javascript - 无法为工具提示制作 css 三 Angular 形

html - 如何叠加图像

c# - 使用 C# : 比较和删除数据表行

c# - DataTable 的新 DataView 与 DefaultView

jquery - 细胞选择数据表 PRIMEFACES?

javascript - 给定的 javascript 语法会做什么?

javascript - 使用 jquery 获取表中特定行的下拉列表的值

javascript - Angular 2 - 为什么动态组件的绑定(bind)被破坏?

html - 拉伸(stretch)空 DIV 100% 并获取它的高度

jquery - MVC3 Action 链接 - 触发 Jquery 的图像按钮