How to make columns made visible by ColVis button searchable

How to make columns made visible by ColVis button searchable

FurburgerFurburger Posts: 37Questions: 8Answers: 0

The columns that are initially hidden in the table have the searchable set to false.

This is important otherwise rows appear in the search results because they have met search criteria in hidden columns but this is confusing to the user (especially if using searchHighlight.js - none of the data is highlighted).

So all hidden columns need to be non-searchable (initially).

If they make a column visible via the colvis, however, the column is not made searchable.

Is there a way to make a column searchable when it is made visible and then not searchable if it is hidden?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    I'm sorry, no. At the moment there is no way to dynamically enable and disable a column's searchable flag after initialisation. The only way is to destroy the table and recreate it with the new settings.

    A getter / setter method for the columns.searchable flag is something that I plan to introduce into the next major version of DataTables.

    Allan

  • FurburgerFurburger Posts: 37Questions: 8Answers: 0

    Hi Allan

    That eould be a great addition to the API.

    Many thanks

This discussion has been closed.