column.index()

Since: DataTables 1.10

Convert between column index formats.

Description

When working with the DOM you will typically be using the visible indexes of columns, since that is the information available in the DOM (when a column is hidden by DataTables, it is removed completely from the DOM, to be re-inserted in future if required to become visible again by column().visible()). However, when working with the raw data of the table, you will typically want to work with the column data index. This method is provided to convert between the two formats.

Type

function column.index( type, index )

Description:

Convert from the input column index type to that required.

Parameters:
Returns:

Calculated column index

Example

Show column index information about a clicked upon column:

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

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

$('#example tbody').on( 'click', 'td', function () {
	var visIdx = $(this).index();
	var dataIdx = table.column.index( 'fromVisible', visIdx );

	alert( 'Column data index: '+dataIdx+', and visible index: '+visIdx );
} );