field().set()
Set the value of a field.
Please note - this property requires the Editor extension for DataTables.
Description
It is often useful to be able to programmatically set the value of a field. This method provides that ability for individual fields.
When used while multi-row editing, this method will set the field value for all items being edited to be the same value (that passed in). If you need the ability to set item values individually, please refer to the field().multiSet() method.
In addition to this method, Editor provides a number of other methods that can be used to get and set field values - each with their own speciality. Please refer to the Related selection below for links to these methods.
Type
field(…).set( value )
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | value |
| No |
The value to set the field to. The format of the value will depend upon the field type. Not required if the first parameter is given as an object. | |||
Returns:
DataTable.Editor.Field: Field instance
Example
Set the values of a few fields before then automatically submitting the form:
editor.create(false);
editor.field('name').set('Test user');
editor.field('access').set('Read only');
editor.submit();Related
The following options are directly related and may also be useful in your application development.