fields.optionsPair
Properties that Editor should use for label and values for options.
Please note - this property requires the Editor extension for DataTables.
Description
A number of field types made available by Editor have the ability to show a list of options to the end user. The built in types are:
The list of options can take a number of different formats (see the fields.options documentation), with the most commonly used being an array of objects. Editor will, by default, look for value and label parameters in those objects, but you can control the parameters used though this option, which can be useful if you already have APIs with a set format that uses other parameters.
This is done by giving this option as an object that has value and label properties. The values given for each will be mapped to the value and label used by Editor.
Note that the datatable field type does not make use of the label property - only the value.
Type
This option can be given in the following type(s):
Example
Using custom properties for the label and value in a list of options.:
var editor = new DataTable.Editor({
ajax: 'php/staff.php',
table: '#myTable',
fields: [
{
label: 'Title:',
name: 'title',
type: 'select',
optionsPair: {
label: 'title',
value: 'id'
},
options: [
{ id: 1, title: 'Mr' },
{ id: 2, title: 'Ms' },
{ id: 3, title: 'Mrs' },
{ id: 4, title: 'Miss' },
{ id: 5, title: 'Mx' },
{ id: 6, title: 'Dr' },
{ id: 7, title: 'Captain' }
]
}
]
});Related
The following options are directly related and may also be useful in your application development.