14. Editor: Unable to find row identifier

Editor requires that each row in a DataTable have a value that will uniquely identify that row. This is used when Editor submits edit and delete requests to the server so the server knows which row should be submitted.

The error:

Unable to find row identifier

will occur when Editor is unable to find the uniquely identifying value.


Each row's uniquely identifying value is a piece of data that is included in the data when DataTables first loads the table. It is typically the database table's primary key value (an auto incrementing integer sequence for example) but it can be any other such as a UUID, a hash or a combination of fields.

By default Editor will look for this value in the property called DT_RowId for each row's data source object. For example, consider the following object that is used to populate a table:

    "DT_RowId":   "row_12",
    "first_name": "Tiger",
    "last_name":  "Nixon",
    "position":   "System Architect",

In this case the DT_RowId property value is row_12 which will be used as the value that will uniquely identify the row to the server.

If this property does not exist in the data source for each row, the error "Unable to find row identifier" may occur.


The key to fixing this issue is to ensure that the unique identifier information (usually the primary key value) is present in the data sent from the server. The data property need not be called DT_RowId, but the data must be present. If the unique identifier is not present, the server-side script must be updated to include this information. The pre-built PHP and .NET libraries automatically use the table's primary key column and alias that to DT_RowId.

If your unique identifier information is not under the name DT_RowId, but is under some other data property name, use the idSrc option to tell Editor where to find it.

In the following example idSrc is used to tell Editor to read the unique row value from the data property id:

var editor = new $.fn.dataTable.Editor( {
    ajax:   '/api/staff',
    table:  '#myTable',
    idSrc:  'id',
    fields: [ ... ]
} );

An example of this is available on the Editor site.