how to search only visible columns
how to search only visible columns

when i am searching in datatable it is searching in hidden columns also. how to search only visible columns only
This discussion has been closed.
when i am searching in datatable it is searching in hidden columns also. how to search only visible columns only
Replies
Apply searchable: false to your hidden columns.
https://datatables.net/reference/option/columns.searchable
i am binding the columns dyanmically.
when i am clicking on column visibility(for particular column like username) button how can i hide that column in search
hello give me reply please
You could also use:
.columns(':visible').search(value);
The solution suggested by @markachten would require that the value is in all columns that are visible since it will do an AND search over the columns rather than an OR search.
Currently there is no API in DataTables to dynamically change the
columns.searchable
flag for a column. You would need to use a custom search plug-in if that is what you wanted to do.Allan
I stumbled upon this issue when I was implementing the Buttons Column Visibility extension. Hidden columns were still searched, which is quite unexpected behaviour in my opinion.
If anyone's interested in solution (or maybe rather an hack), here it is:
Not sure how well this will work on thousands of rows though.
Based on your example from https://datatables.net/examples/api/show_hide.html, if you are toggling the filed I would suggest:
Is this problem resolved in core ?
No, the core behaviour is as described - you are still able to search on hidden fields,
Colin