在数据表中呈现的性能问题

我试图渲染大约2500行禁用排序和“bDeferRender”:true。 它需要40秒左右的铬(v27)。 我正在使用Datatables 1.9和jquery 2.有什么建议吗?

我的数据表的数据表settings

 var oSettings = { 'bDestroy': true, "bInfo": true, "bProcessing": true, "bDeferRender": true, 'iDisplayLength': 10, 'sPaginationType': 'full_numbers', 'sDom': ' Tlfrtip', 'sPageButtonActive': "paginate_active", 'sPageButtonStaticDisabled': "paginate_button", "oLanguage": { "sSearch": "Futher Filter Search results:", "sInfo": "Got a total of _TOTAL_ results to show (_START_ to _END_)", "sLengthMenu": 'Show ' + '5' + '10' + '15' + '20' + '25' + ' results' }, "bSort": false }; 

快速猜测:你正在使用类似于oTable.fnAddData(cells) ,每行一次。 这将导致DataTable在每次添加后重绘。 添加第二个参数false ,例如, oTable.fnAddData(cells,false) 。 然后在循环之后调用oTable.fnDraw() 。 这将只重绘一次而不是2500次。

看到这个小提琴: http : //jsfiddle.net/V2Kdz/

单击“填充”按钮以填充表格。

第12行是:

 var ai = t.fnAddData(cells,false); 

如果redraw参数为false,则表格会在一秒钟之内(在我2011年中期的Mac Air上)。 如果将redraw参数设置为true(或删除它,因为默认值为true),则需要一分钟。