row().id()
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:
Name Type Optional 1 hash
Yes - default:false true
- Append a hash (#
) to the start of the row id. This can be useful for then using the id as a selectorfalse
- Do not modify the id value.
- 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.