edit()

Since: Editor 1.0

Edit an item using the main editing display.
Please note - this property requires the Editor extension for DataTables.

Description

This method is used to edit one or more items, optionally showing the edit form to the end user, providing them with the ability to modifying field values, or the form can be submitted programmatically without user intervention.

As of v1.5 Editor supports the ability to edit the values for one or more rows simultaneously by passing a suitable DataTable.RowSelector option in as the first parameter to this method. Furthermore, it is possible to use DataTable.ColumnSelector and DataTable.CellSelector selectors to edit all values in a column or individual cells using the object form of this option as detailed below. Finally, row, column and cell selectors can all be used simultaneously to provide complex editing options should you wish to utilise this ability in Editor.

When called, this method will set field values in the form to the record's current values automatically. If a field does not have a current value (specifically that it is not undefined), its value in the editing interface will be set to the default value as set by fields.def.

This method has two different styles of being called (see above). Editor will automatically detect which method is used and act accordingly. Although the newer style introduced in Editor 1.3 is preferred for its flexibility, the older style is still retained for backwards compatibility and can continue to be used.

Types

edit( items [, show ] [, options ] )

Since: 1.3

Show the edit entry form allowing the user to enter and modify information for the item to be edited and then subsequently submit that data.

This new form of the edit() method was introduced in Editor 1.3 to take advantage of the the updated chaining interface and form configuration options.

Parameters:

Returns:

DataTable.Editor: Editor instance

edit( items [, title [, buttons [, show ]]] )

Since: 1.0

Show the edit entry form allowing the user to enter and modify information for the item to be edited and then subsequently submit that data.

This older form of the edit() method is retained in Editor 1.3 for full backwards compatibility, but the new form, documented above, is preferred.

Parameters:

Returns:

DataTable.Editor: Editor instance

Examples

Edit the first row in a DataTable, setting a title and buttons:

editor
	.title('Edit record')
	.buttons('Update')
	.edit('#example tbody tr:eq(0)');

Edit the first row in a DataTable, setting a title and buttons. This achieves exactly the same as the example above, but using the form-options parameter.:

editor.edit('#example tbody tr:eq(0)', {
	title: 'Edit record',
	buttons: 'Update'
});

Open a DataTables row for editing and submit immediately, without user interaction:

editor
	.edit(row, false)
	.set('name', 'Updated name')
	.set('access', 'Read only')
	.submit();

Edit all selected rows in a DataTable:

editor.edit(table.rows({ selected: true }).indexes());

Edit a DataTables' selected cells:

editor.edit({
	cells: table.cells({ selected: true }).indexes()
});

Edit a column in a DataTable (column index 1 in this case):

editor.edit({ columns: 1 });

1.0 style API - Show the edit form for the first row in the DataTable with a submit button:

editor.edit('#example tbody tr:eq(0)', 'Edit record', 'Update');

Related

The following options are directly related and may also be useful in your application development.