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?

JoeBokJoeBok 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

  • kthorngrenkthorngren Posts: 21,354Questions: 26Answers: 4,955
    Answer ✓

    One option might be to remove the default search input, using the dom option, and create your own. In your event handler use columns().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 use columns().search(), passing in the array of visible columns as the column-selector, to search only the visible columns.

    Kevin

Sign In or Register to comment.