Having trouble getting shared control in ColVis to work
Having trouble getting shared control in ColVis to work

I'm trying to get the ColVis plugin to work over three separate tables. I tried using the example code on this page:
http://www.datatables.net/release-datatables/extras/ColVis/two_tables_identical.html
However, while it does limit the display to one set of controls, it only affects the first table, and not the others.
I notice, too, that the example page itself doesn't seem to have a working ColVis control either. It's not even visible on both Firefox and Chrome.
Another issue: putting oColVis options inside the oTable = $('table').dataTable() block doesn't seem to affect the final rebuild of the table when oColVis.fnRebuild() is invoked later (as in the example code block). Is there a way to make sure that any options I set for oColVis inside there will get passed into the rebuild? Perhaps in the constructor for a new ColVis object? Maybe I just haven't looked in the right documentation.
Here's the code blocks I'm working with.
[code]
$(document).ready(function() {
var oTable = $('table').dataTable( {
"aaSorting": [],
"bSort": false,
"bPaginate": false,
"aoColumns": [
{ "mDataProp": "feature" },
...
],
"aoColumnDefs": [ { "bVisible": false, "aTargets": [5,6,7,8,9,10,11] } ],
"sDom": '<"clear">rt',
"oColVis": {
"aiExclude": [0,1,2],
"sSize" : "css"
}
} );
var oColVis = new ColVis( oTable.fnSettings() );
$(oColVis).bind('stateChange', function (e, data) {
var jqTables = $('table');
for ( var i=0, iLen=jqTables.length; i
http://www.datatables.net/release-datatables/extras/ColVis/two_tables_identical.html
However, while it does limit the display to one set of controls, it only affects the first table, and not the others.
I notice, too, that the example page itself doesn't seem to have a working ColVis control either. It's not even visible on both Firefox and Chrome.
Another issue: putting oColVis options inside the oTable = $('table').dataTable() block doesn't seem to affect the final rebuild of the table when oColVis.fnRebuild() is invoked later (as in the example code block). Is there a way to make sure that any options I set for oColVis inside there will get passed into the rebuild? Perhaps in the constructor for a new ColVis object? Maybe I just haven't looked in the right documentation.
Here's the code blocks I'm working with.
[code]
$(document).ready(function() {
var oTable = $('table').dataTable( {
"aaSorting": [],
"bSort": false,
"bPaginate": false,
"aoColumns": [
{ "mDataProp": "feature" },
...
],
"aoColumnDefs": [ { "bVisible": false, "aTargets": [5,6,7,8,9,10,11] } ],
"sDom": '<"clear">rt',
"oColVis": {
"aiExclude": [0,1,2],
"sSize" : "css"
}
} );
var oColVis = new ColVis( oTable.fnSettings() );
$(oColVis).bind('stateChange', function (e, data) {
var jqTables = $('table');
for ( var i=0, iLen=jqTables.length; i
This discussion has been closed.
Replies
Does anyone have a similar problem and can help me out? I've got a deadline tomorrow...Thanks.
Michael
http://www.datatables.net/release-datatables/extras/ColVis/two_tables_identical.html
is the correct code after all! That worked.
You definitely should update the example code however on that page. It's non-operational.
Michael
Thanks for sharing your experience. I had the same trouble, spent a couple of hours on it and found your comment. Thanks!