row()
Select a single row from a table.
Description
Working with rows is a fundamental part of DataTables, and you want to be able to easily select the rows that you want from the table. This method is the row counterpart to the columns()
and cells()
methods for working with columns and cells in the table, respectively. Using a selector and the selector-modifier
option the rows at the table can be obtained with this method's own chained methods providing the ability to get the data from the rows, the row nodes and to invalidate the data, among other actions.
Note that if the selector used matches multiple rows, this method will truncate the result to contain just one row, the first matched one. If you require to work with multiple rows at the same time for group manipulation, please use this method's plural counterpart rows()
which can select and manipulate multiple rows.
Type
function row( rowSelector [, modifier ] )
- Description:
Select a row found by a row selector
- Parameters:
Name Type Optional 1 rowSelector
No Row selector.
2 modifier
Yes - default: Option used to specify how the rows should be ordered, and if paging or search options in the table should be taken into account.
- Returns:
DataTables API instance with selected row in the result set
Examples
Select row with a given id:
let row = table.row('#myId');
Select a row of given index:
let row = table.row(1);
Select row with matched data using a function:
let row = table.row((idx, data) => data.location === 'Edinburgh');
Related
The following options are directly related and may also be useful in your application development.