val()
Get or set the value for one or more fields.
Please note - this property requires the Editor extension for DataTables.
The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please sign-in, alternatively an Editor license can be purchased on this site, or sign up for the free trial.
Description
It is often useful to be able to get and set the value of a field, or multiple fields, for example in client-side validation, or data manipulation. This method provides that ability for one or more fields in a form.
When used with multi-row editing, the values returned and set for fields have the following behaviour for this method:
- As a getter, for each field:
- If all items being edited have the same value for the field, that value is returned
- If the items being edited have different values for the field,
undefined
is returned.multiGet()
orfield().multiGet()
should be used to access individual values if this is the case.
- As a setter, for each field:
- The field value is set to the same value for all items being edited. Use
multiSet()
orfield().multiSet()
to set individual values if required.
- The field value is set to the same value for all items being edited. Use
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.