I've been currently struggling with this problem for days. The problem is how can I makes the 'click' on the select all checkbox on thead of datatables to trigger something (in this case, a "disabled" class for my buttons)?
I've makes the trigger work when user 'click' the checkbox one by one, but I can't make it works when user click the select all checkbox. Please help me, thankyou in advance.
This is my Datatables script:
$(document).ready(function () {
table = $('#em').DataTable({
"scrollY": "45vh",
"scrollX": true,
"scrollCollapse": true,
"paging": false,
"responsive": true,
"aaSorting": [1, 'desc'],
"iDisplayLength": 5,
"ajax": {
"url": "/Eromo_Web/inv?act=getAll",
"type": "POST",
"dataSrc": ""
},
"columnDefs": [
{
'targets': 0,
'checkboxes' }
}
],
"columns": [
{"data": null},
{"data": "CODE"},
{"data": "TYPE"},
{"data": "NAME"},
{"data": "KIND"},
{"data": "MERK"},
{"data": "MODEL_TYPE"},
{"data": "LOC"},
{"data": "BUY_DATE"},
{"data": "USERNAME"},
{"data": "DESCR"},
{"data": "RFRGRNT"},
{"data": "MANF"},
{"data": "COUNTRY"}
]
});
My current click trigger:
//getting ID on checkbox click
$('#em').on('change', null, function () {
if (table.column(0).checkboxes.selected().length > 0) {
$('#generateqrcode').attr('disabled', false);
} else {
$('#generateqrcode').attr('disabled', true);
}
if (table.column(0).checkboxes.selected().length === 1) {
ID = "";
$.each(table.column(0).checkboxes.selected(), function (key, value) {
ID = value["CODE"];
});
$('#update').attr('disabled', false);
$('#delete').attr('disabled', false);
} else {
$('#update').attr('disabled', true);
$('#delete').attr('disabled', true);
}
});
Aucun commentaire:
Enregistrer un commentaire