Filter rows based on data existing in a particular column
Filter rows based on data existing in a particular column
I have a table that displays all the departments that faculty members belong to (sample at http://live.datatables.net/bekoceka/1/ ). The full table has more than 400 faculty members. I am trying to find a way to use a <select> element to filter the table to only the selected category.
In my sample table this means if you select "Gene Regulation" in the external drop-down, only the rows with an x in the Gene Regulation column will be displayed (i.e. only John's row will display). Selecting a different category, like Neuroscience will display the 3 matches, Samuel, Lori and Anne.
- I will be changing the displayed content of the cell from just an 'x', so selection can't be based on the x, but that there is/isn't content in the cell.
- All columns will always display.
- I want the solution to work along with the search field filter (both take effect)
The class of each data cell currently matches the option value. I do have access to change the code that generates the HTML, so I can change classes in various places as needed.
I'm brand new to DataTables and I've been stuck on this a couple days, so I would really appreciate some help.
Thanks,
Brian
Answers
You can try my yadcf for filtering datatables http://yadcf-showcase.appspot.com/
go over example and see if it fits you
Thanks for responding Daniel! You have some really cool filter options. However, all the examples I see there set filters that each affect only one column, but I'm wanting to create one filter that can affect multiple columns and I'm not sure how to accomplish that (whether using your plugin or not).
Perhaps another approach for thinking about this would be ordering... Click on a column and instead of changing the order, hide the empty cells in that column. Would that be easier? I would prefer my original approach of a select field triggering the filter, but this could be an acceptable plan B.
Sorry, I'm still lost so I need help from someone who understands how to work with DataTables to find a viable solution.
That's sound like a possible new feature to be added to yadcf... you can open it and I will add it to yadcf... eventually I'll use datatables API under the hood ;) so I guess it possible (think I saw it somewhere before on the board)