How to filter Datatable with default checked checkbox
How to filter Datatable with default checked checkbox

Hello,
i use the following to filter the datatable.The checkbox's default value is "not checked".It works fine.
But when the datatable loads,i want it to be filtered by the checkbox which i want it to be checked by default and show only the 'active' employees.
$('input:checkbox[name="chk_active"]').on('change', function () {
//build a regex filter string with an or(|) condition
var filter = $('input:checkbox[name="chk_active"]:checked').map(function() {
return this.value;
}).get().join('|');
table.column(1).search(filter ? '^((?!0).*)$' : '', true, false, false).draw(false); // active:1 disabled:0
});
Thank you.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Allan,Colin??Any help please?
The
searchCols
is used for defining an initial Datatables column search. See if it will work for you.Kevin
Yes, 'searchCols' did the trick!
Thank you so much!