Changing Column Visibility on Multiple Tables
Changing Column Visibility on Multiple Tables

I'm using DataTables to display the results of Canoe/Kayak/SUP races that I have collected. I want to give users the ability to customize the display—for instance, displaying a straight list of times, or first grouping by Class or BoatType. The code is working fine when there is a single table on a page, but sometimes there are multiple tables (because there were separate events). While sorting and grouping update fine across all the tables, I can't get column visibility to do the same. I've seen code that supposedly does this, but I can't get it to work. Your thoughts are welcome!
Example of a page: http://live.datatables.net/hicibare/1/edit
Replies
I couldn't see in your code where you're trying to change the visibility, but you should just be able to do what you're doing with your search, i.e.
would be
Cheers,
Colin
Colin. Thanks. That's what I thought too (and is the code I'm using). However, it only effects the first table. I'm not sure if this is a bug, but the behavior seems unexpected, since similar code affects all the tables.
Ah, as there's more than one column (two in total), you need to use
columns()
- see here.Colin
Yes! Thank you!
Although it only makes the columns and not the headers visible....interesting.
Colin's example hides the table headers in both tables. Is this what you are asking or is there a different issue?
Kevin
Colin's example does make the change the visibility of the data in the specified column across all the tables. However, it then throws a fatal error that causes the javascript to stop running. I think the problem is in whatever routine writes the column header/labels. I'm playing around with a simpler version here: http://live.datatables.net/kajaqeso/1/edit which appears to replicate the problem.
NB The Grouping isn't working in this example because I couldn't figure out how to reference the column for hardcoded data; neither numbers nor strings seemed to work.
There were several problems with that fiddle:
order()
that didn't existI've tidied up
none
here, and that seems to be working as expected.Colin