field().isMultiValue()
Determine if a field has different values for the items being edited.
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
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