Hide Column when select an option from external dropdown menu
Hide Column when select an option from external dropdown menu
hsnclk1985
Posts: 6Questions: 1Answers: 0
Hi,
I have an external dropbox and there are 3 options in the dropdown menu.
these are;
101,102,104
For example, when I select 101, I want to hide one of the column, As you see in the picture below(click the link), I want to make this, when I select 101, I want to hide 1, make visible 2, and when I select 102, I want to hide 2, make visible 1...
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Try attaching an 'onchange' event handler to the dropdown menu and use the .visible().
Single column
https://datatables.net/reference/api/column().visible()
Multiple columns
https://datatables.net/reference/api/columns().visible()
How can I associate dropdown menu to the releated columns ? can you give examples
You would use the API methods that @jr42.gordon linked to. There are examples in those reference pages. Primarily you use the
column()
selector method to select the columns you want to target.Allan
Here is an example showcasing both single and multiple column hiding.
http://live.datatables.net/toxozezu/3/edit?js,output
This is assuming you are not using colReorder as that provides a certain level of complexity.
Thank you so much jr42.gordon, you're perfect :)