{hero}

field().multiSet()

Since: Editor 1.5

Set the values for a field (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 , alternatively an Editor license can be purchased on this site, or sign up for the free trial.

Description

Multi-row editing is a powerful feature in Editor, particularly if you have the ability to programmatically set individual values for items being edited. This method provides exactly that ability and thus makes possible features such as an Excel like AutoFill, row reordering and other advanced features.

To illustrate this method, 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 there is a field called first_name we might initially use field().multiGet() to find the following:

editor.field('first_name').multiGet();

// Result:
//  {
//      "row_27": "Allan",
//      "row_31": "Bob"
//  }

The individual values can be modified thus:

editor.field('first_name').multiSet( 'row_27', 'Fred' );

editor.field('first_name').multiGet();

// Result:
//  {
//      "row_27": "Fred",
//      "row_31": "Bob"
//  }

Note how this single field can have multiple values assigned to it for each item being edited. The values can match or be different as in the case above. 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 set the value for all items being edited by not passing in an id parameter (this is the equivalent of using the field().val() or field().set() methods):

editor.field('first_name').multiSet( 'Fiona' );

editor.field('first_name').multiGet();

// Result:
//  {
//      "row_27": "Fiona",
//      "row_31": "Fiona"
//  }

The field().multiGet() method provides the getter version of this method. Additionally, use multiSet() if you wish to set multiple items to different values.

Note that there is no field().multiVal() method like there is for single value editing, as such a method's arguments could potentially be ambiguous. Thus the distinction between field().multiGet() and field().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.