field().update()
Update the options available for list field types.
Please note - this property requires the Editor extension for DataTables.
Description
Important: This method is only available on fields which provide a list of options to the end user! The built in field types with this ability are:
Plug-ins such as that for Select2 may also provide this method, please check their documentation for full details and all methods available for each. If this method is called on any other field types (e.g. text) an error will be thrown as the function will not exist.
This method is used to dynamically update the list of options that the user can select from. It can be used to fully replace the existing list of options, or optionally to append new options to the existing list. Note that the order is determined by the array passed in - the field types don't attempt to sort the options.
Type
field(…).update( options [, append ] )
Update the list of options that a user can select from in list field types (checkbox, radio and select).
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | options | No | |
The new options. The data structure given should match that used by the | |||
| 2 | append | Yes - default:false | |
Since 1.6: Flag to indicate if the new options should be appended to the existing list of options, or if they should entirely replace the current list (which is the default action). | |||
Returns:
DataTable.Editor.Field:
The field instance is returned to allow method chaining.
Example
Update options for a field:
editor
.field('title')
.update(['Mr', 'Ms', 'Mrs', 'Miss', 'Mx', 'Dr', 'Captain']);Related
The following options are directly related and may also be useful in your application development.