hide()
Remove one or more fields from the form display.
Please note - this property requires the Editor extension for DataTables.
Description
This method provides the ability to hide a field from the end user at any time. This can be useful for cases when you want to have extra form fields available, but only show them under certain conditions (for example when a particular value is selected, you might provide further options based on that value). Fields which will never be visible to the end user can use the hidden field type.
When a field is hidden, it is still part of the form and will be submitted with the other fields to the server, when the form is submitted, but it simply won't be visible to the user. The clear() method is used to completely remove fields if required.
This is the inverse of the show() method.
Note that the field().hide() method introduced in Editor 1.3 provides the same functionality as this method for individual fields. Both forms will continue to be supported in future versions of Editor, and they can often be used interchangeably for single fields. The key difference is in the return value - this method will return a DataTable.Editor instance, while the field().hide() method returns a DataTable.Editor.Field instance. This can effect how you chain methods if you are using the returned value for chaining.
Type
hide( [ fieldName [, animate ] ] )
Remove one or more fields from the form display.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | fieldName | No | |
The field name to be removed from the display. Multiple fields can be hidden in a single call by providing an array of field names, or all fields hidden by not passing a value for this parameter. | |||
| 2 | animate | Yes - default:true | |
If the field is visible on screen (i.e. the form is shown), by default Editor will attempt to animate the hiding (animating the height to | |||
Returns:
DataTable.Editor: Editor instance
Examples
Show a 'create' record form, but with some fields hidden:
editor
.hide(['account_type', 'access_level'])
.title('Create new user')
.buttons('Save')
.create('Add new user');Show a single field by hiding all and then showing one:
editor.hide().show('access_type');Show and hide a field, based on user input:
$('input', editor.node('dept')).on('change', function () {
if (editor.val('dept') === 'Marketing') {
editor.show('marketing-section');
}
else {
editor.hide('marketing-section');
}
});