Individual column searching : Filter on checkbox state
Individual column searching : Filter on checkbox state
Hi,
I mix different type of searching in a signe table :
Individual column searching (text inputs) -> column 0
Individual column searching (select inputs) -> column 1
Custom Individual column searching (select inputs) -> column 2
And I try to filter the column 3 depending the checkbox filter....
Don't take care to the last function which try to do it (it's probably completely false).
To resume I would like that when you check the checkbox "Agree" to see all the checked row...
Thank you for your help.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
This example from this thread shows how to filter on the checkbox checked state using a search plugin.
Kevin
Thanks guys, seems helpful.
During this time I've updated my example with something less messy :
http://live.datatables.net/yipolina/1/edit
Still not working with the checkbox but may be I will be able to make something with your example @kthorngren , it is a really different function that the one that I use but it is really similar.
OK it's working.
http://live.datatables.net/yipolina/4/edit
Thanks
With a fair amount of research and trial and error, I solved a similar requirement for myself.
I use as well a checkbox, which selects the row.
Trigger is a button for switching between selected and all rows.
The biggest challenge was to make it include selected rows from **all **pages.
@Schmurtz
Sorry, i know this is an old thread, but the checkbox filtering is EXACTLY what I have been looking for.
http://live.datatables.net/yipolina/4/edit
How would you apply this functionality to multiple columns?
Simply adding additional column indexes into the this.api.columns([ ])... doesn't work correctly. Is it due to multiple items with the same id?
@thegamechangerpro
There are a couple issues I see with that solution:
var checked = $('#chk_' + dataIndex).prop('checked');
but this variable is not used in the plugin. It is searching the DOM for that ID. Searching the DOM can be slow so its best to avoid in the search plugin.You want the search plugins to be as efficient as possible especially as the row count increases.
I would do something more like this:
http://live.datatables.net/yipolina/175/edit
It uses assigns the same name to the checkboxes in the column. It uses a global variable to keep track of which columns, by checkbox name, that are checked, ie want to filter by the checked rows.
It uses a variable
checkboxNames
to define the checkbox names by column index (key). This can be changed to derive the names from the column classname or title or whatever.Kevin