{hero}

cells().indexes()

Since: DataTables 1.10

Get index information about the selected cells.

Description

DataTables stores the data for rows and columns in internal 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 rows(), columns() and other API methods which use selectors.

Usefully, this method also provides the visible column index as well as the column data index, as columns can be added and removed from the document dynamically.

The data structure returned for each cell in the result set from the cells() selection method is:

{
    "row":           integer, // Row index
    "column":        integer, // Column data index
    "columnVisible": integer  // Column visible index
}

Type

function cells().indexes()

Description:

Get row, column and visible column index information

Returns:

DataTables API instance with cell index information in the result set

Example

Get column indexes for every cell which contains the value '21':

var table = new DataTable('#myTable');

var columns = table
	.cells(':contains("21")')
	.indexes()
	.pluck('column')
	.sort()
	.unique();

alert('Columns containing 21: ' + columns.join(', '));

Related

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