idSrc

Since: Editor 1.2.3

JSON property from which to read / write the row's ID property.
Please note - this property requires the Editor extension for DataTables.

Description

Editor needs to have the ability to uniquely identify rows when being used as a DataTable editor. This is needed in order to be able to tell the server what row is being edited, or should be removed from the database.

By default Editor will use the DT_RowId property from the data source object. The DT_RowId property is a special one in DataTables as it will be automatically assigned as the row's DOM node id. This is not required for Editor to function correctly, but it can be useful, particularly when working with the rows() selector options.

This property can be set to any value, using the same dotted Javascript object notation options as the columns.data DataTables option. This provides the ability to read data from nested object parameters (see example below).

Types

string

When using DataTables with object based row data (which is the standard data source for Editor, and what the PHP and .NET libraries use), this option provides the property name from which to read the row id from the row's data source object.

integer

When using DataTables with array based row data, this option gives the array index from which to read the row id from the row's data source array.

Default

  • Value: DT_RowId

Use the DT_RowId property from the data source object.

Examples

Use the property id from the data source object as the row id:

/* Data structure:
	{
		"id": 45,
		"name": "Tiger Nixon",
		"position": "System Architect",
		...
	}
*/

var editor = new DataTable.Editor({
	ajax: 'php/staff.php',
	table: '#myTable',
	idSrc: 'id'
});

Use a nested property as the row id:

/* Data structure:
	{
		"user": {
			"id": 45,
			"name": "Tiger Nixon",
			"position": "System Architect"
		},
		...
	}
*/

var editor = new DataTable.Editor({
	ajax: 'php/staff.php',
	table: '#myTable',
	idSrc: 'user.id'
});