field().disable()
Disable a field, disallowing user input.
Please note - this property requires the Editor extension for DataTables.
Description
It can at times be useful to disable a field, preventing the user from modifying the field's current value. This method provides exactly that ability.
While the field is disabled, it can still have its value modified by field().set(), field().val(), etc.
This is the inverse of the field().enable() method, which will enable a previously disabled field.
Note that the disable() method also provides the ability to disable a field, and extends that capability to being able to disable multiple fields in a single call. As such, these two methods can often be used interchangeably. The key difference is in the return value - this method will return a DataTable.Editor.Field instance, while the disable() method returns a DataTable.Editor instance. This can effect how you chain methods if you are using the returned value for chaining.
Type
field(…).disable()
Disable the field, preventing the end user from altering the field's value.
Returns:
DataTable.Editor.Field: Field instance
Examples
Show a 'create' record form, but with a field disabled:
// Note that field().disable() returns a `DataTable.Editor.Field` instance, so
// the Editor methods must be used on the `editor` variable here
editor.field('account_type').disable();
editor
.buttons('Save')
.title('Save')
.create();Disable a field, and then set a value for it:
editor
.field('first_name')
.disable()
.val('Allan');