This example shows how the API that ColVis presents can be used to control the column visibility of two tables with a single instance of ColVis. The result is that changing a button state will effect all tables on the page. This can be useful when looking at multiple tables which have the same column structure.
$(document).ready( function () { var oTables = $('table').dataTable( { "sDom": 'lfrtip' } ); var oColVis = new ColVis( oTables.fnSettings() ); $(oColVis).bind('stateChange', function (e, data) { var jqTables = $('table:not(#example)'); for ( var i=0, iLen=jqTables.length ; i<iLen ; i++ ) { $(jqTables[i]).dataTable().fnSetColumnVis( data.iColumn, data.bVisible ); } } ); document.getElementById('buttonInsert').appendChild(oColVis.dom.wrapper); oColVis.fnRebuild(); } );