Issue Combining SearchPanes and Column Visibility
Issue Combining SearchPanes and Column Visibility
![mayur.patil@smart360.biz](https://secure.gravatar.com/avatar/dec56d978c1c47f8dfef457bc27b3284/?default=https%3A%2F%2Fvanillicon.com%2Fdec56d978c1c47f8dfef457bc27b3284_200.png&rating=g&size=120)
Hi DataTables Team,
I'm currently working on a project where I need to use both the SearchPanes and Column Visibility features of DataTables. I noticed that when these features are combined, there seems to be a problem with synchronization, as SearchPanes sometimes reflects hidden columns or behaves unexpectedly when columns are toggled.
Here are the steps to reproduce the issue:
Initialize a DataTable with both SearchPanes and Column Visibility enabled.
Hide one or more columns using the Column Visibility control.
Observe the behavior of the SearchPanes — they still show search options for hidden columns.
Expected Behavior:
SearchPanes should dynamically update to reflect only the visible columns or seamlessly handle changes in column visibility.
Current Behavior:
SearchPanes continues to display values for hidden columns, which creates confusion for users.
Could you please advise on the correct configuration or workaround to ensure these two features work well together? If this is a known issue, is there any timeline for a fix or an alternative approach I can use?
Thanks for your assistance and support.
Replies
It is indeed quote possible for hidden columns to be used with SearchPanes. If you want to discount certain columns from SearchPanes, use
searchPanes.columns
.Allan
Thank you for your response. I appreciate the guidance regarding the searchPanes.columns option.
I understand that I can manually specify columns for SearchPanes, but my requirement is to dynamically update the SearchPanes based on the current column visibility state. Specifically:
-When a column is hidden using the Column Visibility control, I would like SearchPanes to automatically exclude that column from the available search options.
-Conversely, when a hidden column is made visible again, its corresponding SearchPane should reappear without requiring a page refresh or manual reinitialization.
Could you please advise if there is a built-in way to handle this scenario or suggest an event-driven approach to achieve this dynamic synchronization?
Thanks for your continued support.
Sorry, there is currently no option in SearchPanes to have it show / hide panes based on the column visibility. I had wondered if calling
rebuildPane
might recalculate the whole thing, but it doesn't and checking the SearchPanes code I can see that it wouldn't. The column resolution is one of the first things that is done.I'll add this to the todo feature list.
Regards,
Allan
Hi Allan,
Thank you for your prompt and detailed response. I truly appreciate you adding this feature request to your to-do list.
In the meantime, I will explore potential event-driven workarounds to handle dynamic column visibility and SearchPanes updates. If you have any suggestions or best practices for approaching this, I would love to hear your insights.
Thanks again for your support and for maintaining such a fantastic library.
column-visibility
is the event to listen to and then show / hide the corresponding pane. I don't know how much you might need to tinker with the layout of the panes if popping them in and out though.Allan