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