DataTables logo DataTables

This site contains the legacy documentation for DataTables v1.9 and earlier for reference only.
DataTables 1.9 was End Of Life in 2014. Do not use it for new work.
The current release of DataTables can always be found on DataTables.net.
ColVis v1.1.0

API

The API for ColVis is fairly simple:

buttonText
Show details
Get the ColVis instance's control button so it can be injected into the DOM
Default:
Input parameters: void
Return parameter: ColVis container element for insertion into the DOM.
Code example:
$(document).ready(function() {
	var table = $('#example').DataTable();
	var colvis = new $.fn.dataTable.ColVis( table );

	$( colvis.button() ).insertAfter('div.info');
} );
fnRebuild or rebuild Why two names?
Show details
Reconstruct the list of columns based on the current visibility (if changed by an external process for example) and the column titles. Note that this function is available as both a static method and an instance method, although typically the static one will be used with a table selecting parameter since the ColVis instances are 'hidden' by DataTables (although accessible through ColVis.aoInstances if you do want them).
Default:
Input parameters:
  1. object - DataTables instance for the ColVis button to rebuild. This parameter is optional. If nothing is passed in ColVis will rebuild all column lists on the page.
Return parameter: void
Code example:
$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sDom": 'C<"clear">lfrtip'
	} );
	
	oTable.fnSetColumnVis( 2, false );
	ColVis.fnRebuild( oTable );
} );