datatables js加快了吗?

时间:2015-02-03 18:39:28

标签: jquery datatables jquery-datatables

我在客户端的数据表中加载超过10000条记录,绑定所有记录需要更多时间,所以我做了以下两个步骤

1. first loaded 100 records in datatables using fnAddData() and fnDraw().
2. remaining records loaded to datatables in settimeout function.

加载前100条记录所需的时间非常快,尽管我使用settimeout函数加载了休息记录,但我面临以下问题

 Page goes to not responding until the records bind to datatables 

任何想法如何解决页面没有响应问题,我需要一次快速加载数据完整记录或者先使用settimeout稍后休息一些记录。

2 个答案:

答案 0 :(得分:2)

您应该考虑使用DataTables提供的server-side options

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "../server_side/scripts/server_processing.php"
    } );
} );

答案 1 :(得分:0)

考虑使用分页。这只会一次将X个记录呈现到DOM中,并允许您遍历页面以查看其余记录。由于您无需将99%的记录呈现到DOM中即可启动,因此可以加快加载速度。

$('#example').DataTable({
    dom: 'lrtip',
    paging: true,
    pageLength: 50,
});