现在我的JQuery Datatable加载大约需要80秒。数据从chrome.storage.local加载,编辑了一下,然后使用
创建数据表$('#matches').DataTable({
data: matches,
columns: [
{ "data": "c1", title: "Character 1" },
{ "data": "c2", title: "Character 2" },
{ "data": "w", title: "Winner" },
{ "data": "sn", title: "Strategy" },
{ "data": "pw", title: "Prediction"},
{ "data": "t", title: "Tier" },
{ "data": "m", title: "Mode" },
{ "data": "o", title: "Odds" },
{ "data": "ts", title: "Time" },
{ "data": "cf", title: "Crowd favor" },
{ "data": "if", title: "Illum favor" },
{ "data": "dt", title: "Date"}
],
columnDefs: [
{ type: 'date-eu', targets: 11 },
{ type: 'odds', targets: 7},
{ searchable: false, targets: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
],
lengthMenu: [ 15, 25, 50, 100 ],
initComplete: function(settings, json) {
$("#loading").hide();
},
createdRow: function ( row, data, index ) {
$('td', row).eq(data.w).addClass('highlight');
},
deferRender: true,
});
其中matches是一个对象数组。
deferRender不起作用,因为数据未加载ajax。什么是让它发挥作用的最佳方法?将数据作为JSON写入临时文件,然后将其用作数据源?