Hide tables - preselected columns
Hide tables - preselected columns
Hi there,
I have been using datatables for a year now and love its flexibility - thank you!
I am using the dynamic show and hide columns example and would like to have certain columns preselected (for hiding). Currently all columns load up and then the user has to individually unselect them. Is there a way to have a preselected list when it loads?
Thanks for your help!
-SDJ
I have been using datatables for a year now and love its flexibility - thank you!
I am using the dynamic show and hide columns example and would like to have certain columns preselected (for hiding). Currently all columns load up and then the user has to individually unselect them. Is there a way to have a preselected list when it loads?
Thanks for your help!
-SDJ
This discussion has been closed.
Replies
It works similar to the dynamic show/hide example: http://www.datatables.net/examples/api/show_hide.html
but uses check boxes instead of the "toggle" links. When the page initially loads, a couple of the check boxes are defaulted to checked and the corresponding columns are hid using ("bVisible": false).
Please let me know if you have any questions about this.
However, I'm now starting to use colVis for this type of functionality instead of the method I mention above.
Thanks very much!
I'm using it in the aoColumns section of the initialization which can be seen in the example on the documentation page.
To toggle the hiding/showing on the columns for which I've added check boxes, the javascript looks like this:
$("#VAR11").change( function() {fnShowHide(8); } );
where 8 corresponds to the table column, the count of which starts with 0 (the left most column is column 0). VAR11 is id of the check box.
However I would also check out the ColVis plug in: http://www.datatables.net/release-datatables/extras/ColVis/
which accomplishes the same thing a bit more easier and potentially more elegantly. It didn't exist back when I had implemented the pages with the check boxes.
Matthew