{hero}

row().id()

Since: DataTables 1.10.8

Get the id of the selected row.

Description

This method can be used to get a row's id, as specified by the row's data and the rowId option. Optionally it can also prepend a hash (#) to the row id allowing it to then easily be used as a selector.

Important This method does not read the DOM id for the tr element, but rather gets the row id from the row's data source (location specified by rowId).

Type

function row().id( [ hash ] )

Description:

Get the id of the selected row.

Parameters:
Returns:

Row id. If the row does not have an id available undefined will be returned.

Example

Click handler that shows row id:

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

$('#myTable').on('click', 'tr', function () {
	var id = table.row(this).id();

	alert('Clicked row id ' + id);
});

Related

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