multiSet()
Set 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
The ability to set multiple items for one or more fields is a core aspect of the Editor multi-row editing API as it provides a very powerful interface for developers to create advanced features such as Excel like autofill and row reordering among others. This method provides that ability.
This method is effectively an extension of field().multiSet()
and the values that can be set are identical apart from the ability to pass an object in that contains the values for multiple fields (this objects structure matches multiGet()
so that object can be manipulated directly and then passed back to this function if required).
To illustrate this method and how it will effect the editing data, 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"
// }
// }
The first_name
field can be modified thus:
editor.multiSet( {
"first_name": {
"row_27": "Allan",
"row_31": "Fred"
},
"last_name": {
"row_27": "Jardine",
"row_31": "Brown"
}
} );
// editor.multiGet() will produce an object identical to that passed in.
We can set the values for a single item:
editor.multiSet( {
"first_name": {
"row_31": "Fred"
},
"last_name": {
"row_31": "Green"
}
} );
editor.multiGet();
// Result:
// {
// "first_name": {
// "row_27": "Allan",
// "row_31": "Fred"
// },
// "last_name": {
// "row_27": "Jardine",
// "row_31": "Green"
// }
// }
Equally a single field can be specified (again notice how not all row values need to be specified):
editor.multiSet( 'first_name', {
"row_31": "Richard"
} );
editor.multiGet();
// Result:
// {
// "first_name": {
// "row_27": "Allan",
// "row_31": "Richard"
// },
// "last_name": {
// "row_27": "Jardine",
// "row_31": "Green"
// }
// }
The multiGet()
method provides the getter 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.