multiGet()
Get the values for one or more fields (multi-row editing aware).
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
Multi-row editing in Editor is a particularly powerful feature, however it needs to be unlocked via the API for developers to make full use of it (beyond the simple options presented to the end user in the Editor UI). This method provides part of that API giving the ability to read the values of fields in a multi-row editing aware manner (unlike get()
and val()
which are not multi-row aware and will give undefined
as the value for any fields which have multiple values).
To illustrate this method and the data that it will return, consider an Editor instance that has been set up to edit two rows in a DataTable which have the row id's of row_27
and row_31
. If form has only two fields first_name
and last_name
we might have:
editor.multiGet();
// Result:
// {
// "first_name": {
// "row_27": "Allan",
// "row_31": "Bob"
// },
// "last_name": {
// "row_27": "Jardine",
// "row_31": "White"
// }
// }
Note that the object structure allows a single field to have multiple values assigned to it, one for each item being edited. The field().isMultiValue()
method can be used to determine if a field contains different values for the items being edited or not.
We can also get the values for a single field (this action can also be performed with field().multiGet()
:
editor.multiGet( 'first_name' );
// Result:
// {
// "row_27": "Allan",
// "row_31": "Bob"
// }
The multiSet()
method provides the setter version of this method.
Note that there is no val()
equivalent method for multi-row editing (i.e. a multiVal()
method), as such a method's arguments could potentially be ambiguous. Thus the distinction between multiGet()
and multiSet()
.
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.