{hero}

column().visible()

Since: DataTables 1.10

Get / set the visibility of a single selected column.

Description

Showing and hiding columns in a DataTable can be quite handy, particularly when showing tables with a large information density. This method allows the visibility of a single column to be changed on-the-fly, or the visibility state of a column to be read.

Types

function column().visible()

Description:

Get the visibility of the selected column.

Returns:

true if the column is visible, false if it is not.

function column().visible( show [, redrawCalculations ] )

Description:

Set the visibility of the selected column.

Parameters:
Returns:

DataTables API instance with selected column in the result set.

Examples

Get the visibility status of column index 0:

var table = $('#example').DataTable();

alert( 'Column index 0 is '+
	(table.column( 0 ).visible() === true ? 'visible' : 'not visible')
);

Hide the first column in the table:

var table = $('#example').DataTable();

table.column( 0 ).visible( false );

Hide multiple columns using redrawCalculations to improve performance:

var table = $('#example').DataTable();

for ( var i=0 ; i<4 ; i++ ) {
	table.column( i ).visible( false, false );
}
table.columns.adjust().draw( false ); // adjust column sizing and redraw

Related

The following options are directly related and may also be useful in your application development.