jquery.dataTables.min.js:数据表1.10.12数据表:JSON是在initComplete未定义()
我需要的数据已经被加载后,可以访问表中的行(deferred)。而我不能因为json
是undefined
对于我initComplete里面的功能。尽管我的表已加载,并且我看到了所有数据。此外,函数内部还有settings
数据。
这是为什么?我忘了一些选择吗?
我的代码:
var data_table = task_submit_table.DataTable({
"initComplete": function (settings, json) {
console.log(json);
},
"processing": true,
"serverSide": true,
"deferRender": true,
"deferLoading": 0,
"ordering": true,
"order": [[ 0, "desc" ]],
"ajax": {
"url": "get_task_list/",
"type": "POST",
"dataType": "json"
},
"columns": [
{"title": "Id", "data": "id"},
{"title": "Date", "data": "date"},
{"title": "Project Id", "data": "project_id"},
{"title": "Project Name", "data": "project_name"},
{"title": "project", "data": "biobank_project"},
{"title": "#Hashes", "data": "nhashes"},
{"title": "#Success", "data": "nsuccess"},
{"title": "#Fail", "data": "nfail"},
{"title": "Status", "data": "status"},
{"title": "Report", "data": null},
{"title": "", "data": null},
{"title": "", "data": null}
],
"columnDefs": [
{
"targets": [0],
"visible": false,
"searchable": true
},
{
"targets": [2],
"visible": false,
"searchable": true
},
{
"targets": -3,
"data": null,
"defaultContent": "<form id='tool-export' method='post' action='export/'>"+
"<a href='#' id='export' class='btn btn-default export-link'>export</a></form>"
},
{
"targets": -2,
"data": null,
"defaultContent": "<a href='#' id='task-delete' class='btn btn-default task-delete-link'"+
"data-toggle='modal' data-target='#confirm_modal'>delete</a>"
},
{
"targets": -1,
"data": null,
"defaultContent": "<a href='#' id='task-restart' class='btn btn-default task-restart-link'"+
"data-toggle='modal' data-target='#confirm_modal'>restart</a>"
}
],
"dom": "<\"dt-btn-floatLeft\"l><\"dt-btn-floatRight\"B><\"dt-btn-clear\">rtip",
"buttons": [
{
"title": "Refresh",
"text": "Refresh",
"action": function() {
data_table.draw();
}
}
]
});
data_table.draw();
尝试将''initComplete''改为''fnInitComplete“' –
没有成功。有设置数据,但json仍未定义。 – trex