Is there a way to toggle the colVisGroup button?
Is there a way to toggle the colVisGroup button?
All the examples I've seen of the ColVisGroup button shows creating two buttons, one to hide the columns and a second to reshow them. Is there a way to have a single button that toggles back and forth between hiding and showing the selected columns?
This question has accepted answers - jump to:
Answers
Yep, you're right, but you can create a custom button fairly easily that mimics the same behaviour - see here,
Colin
That is like the most awesome and easy answer ever! Thanks!! If I could trouble you to help me with one more piece...ultimately I'm trying to load in sections from a database dynamically, I'm really close to having it figured out but am stuck on one piece. I altered your demo so that it's a collection of buttons, and am adding the individual group buttons after the DataTable is created. For some reason though when it's cycling through the group buttons, it's only hiding/showing the last group no matter which one I've selected. Can you take a look at my revised demo and see if you can spot what I'm doing wrong?
live.datatables.net/rojujubo/2/edit?html,js,console,output
The problem was that "secID" is being over-written as it goes through the loop - and the
action
function would be called using the last time it was set, i.e. that second grouping.The fix is to do something like this: http://live.datatables.net/rojujubo/4/edit . Here I've stored the secID in the className, and then just retrieve that to use for the visibility.
Colin
Much, much appreciated!!! You've helped to make the public school teachers of Louisville, KY a much happier group of people!