column().index()

Since: DataTables 1.10

Get the column index of the selected column.

Description

DataTables stores the data for rows and columns in internally indexes which it can utilise for fast operation of ordering, searching etc. It can be useful at times to know what these indexes are, as they can be used for efficient selectors in the row(), column() and other API methods which use selectors.

This method is used to retrieve the index of the selected column. By default it will return the column data index (i.e. column visibility is not taken into consideration), but by passing visible as the first parameter to the method, the returned indexes will be the columns' visible index, which does take into account hidden columns (for example if column 0 is hidden, all following columns would have their visible index shifted by 1).

Type

function column().index( [type] )

Description:

Get the column index of the selected column.

Parameters:
Returns:

The column index for the selected column.

Example

:

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

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

var idx = table.column( 1 ).index( 'visible' );
alert( idx ); // will show 0

Related

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