Since: DataTables 1.10

Get index information about the selected cell.


DataTables stores the data for rows and columns in internal indexes for fast 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.

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 the cell in the result set, selected by cell() is:

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


function cell().index()


Get row, column and visible column index information


Object with index information for the selected cell. See below for the object structure.


Alert the visible column index (count) for the cell clicked on:

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

$('#example tbody').on( 'click', 'td', function () {
	alert( 'Clicked on cell in visible column: '+table.cell( this ).index().columnVisible );
} );

Use row index in a row selector to add a class to the clicked on row:

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

$('#example tbody').on( 'click', 'td', function () {
	var rowIdx = table
		.cell( this )

		.rows( rowIdx )
		.addClass( 'clicked' );
} );


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