javascript - DataTables: json is undefined in initComplete() -
jquery.datatables.min.js: datatables 1.10.12
i need access table rows after data has been loaded (deferred). , can't because json
undefined
me inside initcomplete function. despite table loaded , see data. also, there settings
data inside function.
why that? did forget option?
my code:
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();
the rows in deferred datatables can accessed via rowcallback function. see full response here https://stackoverflow.com/a/40659721/2393924
Comments
Post a Comment