How do I sync column visibility with searchable based on user selections with ColVis button?
How do I sync column visibility with searchable based on user selections with ColVis button?
JoeBok
Posts: 1Questions: 1Answers: 0
I am applying datatables to DataGrids and GridViews from an ASP.net app. Users want to show or hide columns, and want the search box to only search visible columns. So I need to figure out how to sync the visible and searchable properties of the columns after colvis wraps up and before the search executes and the table draws. Can somebody point me in the right direction? Many thanks!
This question has an accepted answers - jump to answer
Answers
One option might be to remove the default search input, using the
dom
option, and create your own. In your event handler usecolumns().visible()
to get the visible columns. You will need to loop through the result to build an array of column indexes that are true. Then usecolumns().search()
, passing in the array of visible columns as thecolumn-selector
, to search only the visible columns.Kevin