multiGet()

Since: Editor 1.5

Get the values for one or more fields (multi-row editing aware).
Please note - this property requires the Editor extension for DataTables.

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.

Type

field(…).multiGet( [ fieldNames ] )

Get the current value(s) of one or more fields

Parameters:

Returns:

object:
If a single field is requested (by passing a string as the parameter to this function) the value returned will be an object where the parameter keys match the row ids for the rows being edited - this is identical functionality to the field().multiGet() method.

        If an array of fields is given, or `-type undefined` to get all fields, an object is returned where the keys are the field names and the values the multi-row editing value of the field (i.e. keys matching the row ids for the rows being edited as per `e-api field().multiGet()`).

Related

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