dashboard-admin/public/assets/js/page/modules-datatables.js
jilhanhaura af7c67312f update
2023-09-08 13:57:36 +07:00

41 lines
1.1 KiB
JavaScript

"use strict";
$("[data-checkboxes]").each(function () {
var me = $(this),
group = me.data('checkboxes'),
role = me.data('checkbox-role');
me.change(function () {
var all = $('[data-checkboxes="' + group + '"]:not([data-checkbox-role="dad"])'),
checked = $('[data-checkboxes="' + group + '"]:not([data-checkbox-role="dad"]):checked'),
dad = $('[data-checkboxes="' + group + '"][data-checkbox-role="dad"]'),
total = all.length,
checked_length = checked.length;
if (role == 'dad') {
if (me.is(':checked')) {
all.prop('checked', true);
} else {
all.prop('checked', false);
}
} else {
if (checked_length >= total) {
dad.prop('checked', true);
} else {
dad.prop('checked', false);
}
}
});
});
$("#table-1").dataTable({
"columnDefs": [
{ "sortable": false, "targets": [2] }
]
});
$("#table-2").dataTable({
"columnDefs": [
{ "sortable": false, "targets": [0, 2, 3] }
]
});