Yes, it is possible to filter a column using a check box. If you have a look at the fnFilter API function ( http://datatables.net/api#fnFilter ) you'll be able to see that you could attach an event listener to the checkbox and use that to apply fnFilter().
It's actually quite difficult to filter on a column with checkboxes in it. The reason for this is that you need to look at the live DOM, rather than the internally cached state in DataTables. It certainly is possible, using the custom filtering options that DataTables provides, but it's non-trivial to do (a reasonably good understanding of Javascript will be required).
There isn't an example of this available at the moment, but I'll add it to my to-do list (which is rather long now, so it won't be any time soon...).
I would like to also filter on a column with checkboxes. Is the situation described above still true (difficult to
filter on a column with checkboxes), or has there been any progress on this since the last post?
After thinking about it some more, it seems that if I added a hidden column and updated the hidden column with the value of the checkbox when it changed, I could filter using the hidden column. Would this approach work?
Also, is there a way to OR the hidden column filter with the global search box? I would like to always display any rows where the checkbox is enabled.
> I would like to also filter on a column with checkboxes
The way to do this is to use a filtering plug-in: http://datatables.net/plug-ins/filtering . With the filtering plug-ins you have full access to the row's data and the nodes for the row - you simply perform your logic on the row and then return true or false to indicate if you want it to be included in the output or not.
What is the interaction that you are looking for between the filter and the checkboxes? Are you looking for the user to type something that it will match against for checked inputs, or do you have a toggle somewhere which indicates if checks rows should be included or not?
Replies
Yes, it is possible to filter a column using a check box. If you have a look at the fnFilter API function ( http://datatables.net/api#fnFilter ) you'll be able to see that you could attach an event listener to the checkbox and use that to apply fnFilter().
Regards,
Allan
it worked perfectly
Is it possible to have an exemple ?
It's actually quite difficult to filter on a column with checkboxes in it. The reason for this is that you need to look at the live DOM, rather than the internally cached state in DataTables. It certainly is possible, using the custom filtering options that DataTables provides, but it's non-trivial to do (a reasonably good understanding of Javascript will be required).
There isn't an example of this available at the moment, but I'll add it to my to-do list (which is rather long now, so it won't be any time soon...).
Allan
OK thank you
bye
filter on a column with checkboxes), or has there been any progress on this since the last post?
Thanks,
Don
Also, is there a way to OR the hidden column filter with the global search box? I would like to always display any rows where the checkbox is enabled.
Thanks,
Don
I also need to filter all rows, but always displaying any rows where the checkbox is enabled.
The way to do this is to use a filtering plug-in: http://datatables.net/plug-ins/filtering . With the filtering plug-ins you have full access to the row's data and the nodes for the row - you simply perform your logic on the row and then return true or false to indicate if you want it to be included in the output or not.
What is the interaction that you are looking for between the filter and the checkboxes? Are you looking for the user to type something that it will match against for checked inputs, or do you have a toggle somewhere which indicates if checks rows should be included or not?
Allan