API

This extension has now been retired and replaced with the column visibility module for Buttons. The documentation is retained for legacy reference only. New projects should use Buttons in preference to ColVis.

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 table = $('#example').dataTable( {
        "sDom": 'C<"clear">lfrtip'
    } );
    
    table.fnSetColumnVis( 2, false );
    $.fn.dataTable.ColVis.fnRebuild( table );
} );