dataSrc
Since: Editor 3.0
.
Please note - this property requires the Editor extension for DataTables.
Description
Editor itself does not hold the data to be edited, but rather needs to get it from an external data store in order to present the data to the end user for editing, and then submit it back to the data store.
In the majority of cases, Editor will get the data to edit from a DataTable (specified with the table option), but it is also possible to get the data from other locations:
html- Get the data from an HTML element matching with an attribute calleddata-editor-fieldwith a value matching the field name(s) to be edited. Example. Use this option when you want editing to happen directly on static HTML elements.ajax- Make an Ajax request to get the data (useajaxto specify the Ajax location). Example. This option is particularly useful if you don't have a DataTable to display a list of records on the page, but want to provide an editing interface to a specific record (for example, allowing a person to edit their profile, but not others).table- the default mode where the data to edit is read from a DataTable based on the modifier used to trigger the editing (typically a row). Example.
Type
This option can be given in the following type(s):
Default
- Value:
table
Get the data to edit from a DataTable.
Example
Set the display type to envelope:
var editor = new DataTable.Editor({
ajax: '/api/data',
dataSrc: 'ajax',
fields: [
// ...
]
});
// Trigger an edit action
editor
.buttons('Save')
.edit('row_1')
.title('Edit');