field().isMultiValue()

Since: Editor 1.5

Determine if a field has different values for the items being edited.
Please note - this property requires the Editor extension for DataTables.

Description

When using Editor's multi-row editing ability, it can be useful to know if a particular field has a common value for all items being edited, or if they are different. This method provides that ability and is used internally by Editor to display the multi-row editing UI to the end user (i.e. the "Multiple values..." message).

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:

var field = editor.field('first_name');

field.multiGet();
// Result:
//  {
//      "row_27": "Allan",
//      "row_31": "Bob"
//  }

field.isMultiValue();
// Result:
//  true

field.val( 'Francis' );

field.isMultiValue();
// Result:
//  false

field.multiSet( 'row_31', 'Fred' );

field.isMultiValue();
// Result:
//  true

Type

field(…).isMultiValue()

Returns:

boolean:
true if the items being edited have one or more different values, false if they are all the same. This will always be false is only a single item is being edited.

Example

Get the value for a specific editing item, and then use it to set the value of all editing items:

var field = editor.field('first_name');

if (field.isMultiValue()) {
	var val = field.multiGet('row_27');

	field.val(val);
}

Related

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