jquery.dataTables.min.js: DataTables 1.10.12
I need to disable export
button if the status is not "success" in the DataTables like this (deferred loading):
The code:
var data_table = task_submit_table.DataTable({
"processing": true,
"serverSide": true,
"deferRender": true,
"deferLoading": 0,
"ordering": true,
"order": [[ 0, "desc" ]],
"ajax": {
"url": "get_task_tasks/",
"type": "POST",
"data": function (d) {
var form_data = {"ukis_project_id": ukis_proj_id.find(":selected").val(),
"task_project_id": task_proj_id.val(), "project_salt": proj_salt.val()};
d.form = JSON.stringify(form_data);
}
},
"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();
I know that I can disable/enable buttons in the Bootstrap with help of disabled/active
classes, like this <a href='#' class='btn btn-default disabled'>export</a>"
.
But how can I get access to those buttons after the table is drawn and data are fetched from the server?
It seems like initComplete "initComplete": function(settings, json) {}
is what I'm looking for. I tried it but only empty array is returned after calling rows() method. And the json
is undefined
.