Since: DataTables 1.10

Get the row index of the selected row.


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.

This method is used to retrieve the indexes of the selected rows which can then be used as part of a selector to update data.


function row().index()


Get the row index of the row column.


Row index


Show an alert with the row index that was clicked upon:

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

$('#example tbody').on( 'click', 'tr', function () {
	alert( 'Row index: '+table.row( this ).index() );
} );

Use the selected row as part of a cells() selector.:

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

$('#example tbody').on( 'click', 'tr', function () {
	var idx = table
		.row( this )

		.cell( idx, 0 ) // note that you could actually pass in 'this' as the row selector!
		.data( 'Updated' )
} );


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