Filtering table data on a specific column when checkbox is checked
Filtering table data on a specific column when checkbox is checked
I have set up a datatable of which I can search through all categories (columns). For the sake of simplicity I'll be referring to a table of DHL packages which has 3 columns:
1. DHL Number
2. Package status (sent, arrived)
3. Date of pickup
on my webpage, I have a checkbox what is supposed to filter out (hide) all packages that have arrived since we should be interested about the packages in transit. And in an unchecked state it should show all packages.
Theoretically I would do a search for "sent" when the checkbox is checked. But how do I do that as js code? What I have done till now is:
dhlList.columns(1).Search('Sent').draw();
And this is my config of that table:
dhlList = $('#dhlList').DataTable({
scrollY: '60vh',
autoWidth: true,
searching: false,
searchable: true,
'aoColumns': [
null,
null,
null,
{ "bSortable": false },
],
'bSortable': [
null,
null,
null,
{ "bSortable": false },
],
paging: false
});
Yet I get the error message that "dhlList.columns(...).Search is not a function".
What am I missing here?
This question has accepted answers - jump to:
Answers
Search is a lower case s
right
and how do I reverse the process? I mean make it show both sent AND arrived packages?
You can use the regex option of the
search()
api.Kevin