colvis, set a maximum
colvis, set a maximum

Hi everybody,
I'm working with datatable colvis and I have some trouble with this button.
What I would like to do :
Allow user to set visibility of a limited number of column inside a larger set.
For example:
the table have 8 columns and only column 1 to 4 are visible
User can click on a button in order to set visibility of columns
but if he set 5 columns visible, then he can't set another one visible, because 5 is a maximum (the limit I want to add)
Is it possible ? And if it's possible, can we change color of columns buttons in order to show that they are disabled ?
Thank you,
Sorry for my english.
This question has an accepted answers - jump to answer
Answers
This is how you count the visible columns:
Then you can use this event to count and check etc
https://datatables.net/reference/event/column-visibility
Yes I knew about that but how to disable buttons in order to prevent user to add another column ?
All you would need to do is to use the search field in the upper right corner...
https://datatables.net/reference/api/buttons().disable()
Oops, sorry.
Thank you for your time !