ids()
Get the ids of the rows being edited.
Please note - this property requires the Editor extension for DataTables.
Description
When working with events in Editor it can often be useful to reference the rows that are being edited in the DataTable - this method provides that ability by giving easy access to the ids of the rows being edited (typically a primary key value from the database) - as defined by the idSrc option (defaults to DT_RowId).
Optionally the method can add a hash in front of each id value for use with the rows() method, allowing node, data, etc selection from the DataTable.
When called while editing or deleting row(s), the values returned reflect the ids of those rows being acted upon. If called while creating a new row, the value return reflect the indexes of the new row(s) being created, starting from 0 (create() allows for multiple rows to be created).
Type
ids( [ includeHash ] )
Gets a list of the ids of the rows being acted upon (create, edit or delete). The ids are defined by the idSrc property.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | includeHash | Yes - default:false | |
Indicate if a hash should be included as a prefix to the ids returned or not. This can be useful if you are selecting the rows from the DataTables API. | |||
Returns:
string[]:
An array that contains the ids of the rows being edited.
Example
Get data for the rows being edited from DataTables:
editor.on('initEdit', function () {
var ids = editor.ids(true);
var data = table.rows(ids).data();
// Do something with `data`...
});Related
The following options are directly related and may also be useful in your application development.