Newbie Question - How to dynamically allow user to display DataTables columns
Newbie Question - How to dynamically allow user to display DataTables columns
As the question subject line mentions I am very new (going on my 2nd day) to the DataTables world. I have been tasked to provide additional functionality to an existing Javascript application that would allow users to dynamically select/indicate what columns of a DataTable they want to see at any given time. I have found through internet searches that the column API has a visible() method that allows the visibility of a column to be turned off and on and the column layout to be performed or not. My design concept is as follows and starts once a the user's DataTable has been populated with all columns from the main repository mongo database.
1) Allow user to select n number of columns
2) Provide new Hide button, once selected execute Javascript code that would call the visible method for each selected column and provide the appropriate show and redrawCalculations attribute values.
3) Provide a new Show All button, once selected execute Javavscript code that would call visible method for all columns previously hidden providing the appropriate show and redrawCalculations attribute values.
Does such design sound correct? Thanks for your time and feedback.
Answers
Have a look at the Buttons extension. Specifically its column visibility buttons.
Allan