Function Select All when use iCheck Style
axstavo08 opened this issue · 1 comments
axstavo08 commented
Hello,
There is a problem when trying select all checkboxes in a column using iCheck style.
I made a JSFiddle
When you try to click on select all checkbox, only this is checked, but the others not.
It only happen when I added property scrollX: true inside options datatable.
Otherwise great work.
Thanks.
mpryvkin commented
This happens because table header is no longer child node to element with ID example
when scrolling is enabled.
Solution is to use table container element using table().container()
API method.
For example:
// Handle iCheck change event for "select all" control
$(table.table().container()).on('ifChanged', '.dt-checkboxes-select-all input[type="checkbox"]', function(event){
var col = table.column($(this).closest('th'));
col.checkboxes.select(this.checked);
});
// Handle iCheck change event for checkboxes in table body
$(table.table().container()).on('ifChanged', '.dt-checkboxes', function(event){
var cell = table.cell($(this).closest('td'));
cell.checkboxes.select(this.checked);
});
See updated example for code and demonstration.