show()
Show one or more fields in the display that was previously hidden.
Please note - this property requires the Editor extension for DataTables.
Description
This method provides the ability to show a field in the end user's displayed form at any time (assuming the field was previously hidden using hide()). 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).
This is the inverse of the hide() method.
Note that the field().show() 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().show() method returns a DataTable.Editor.Field instance. This can effect how you chain methods if you are using the returned value for chaining.
Type
show( [ fieldName [, animate ] ] )
Show one or more fields in the form display.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | fieldName | No | |
The field name to be displayed. Multiple fields can be shown in a single call by providing an array of field names, or all fields displayed 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 field show by animating the height. This option can be used to override the animation and show the field immediately. If the field is not visible on the page, its display property is set to show immediately. | |||
Returns:
DataTable.Editor: Editor instance
Examples
Show all fields in a form instance:
editor.show();editor
.hide(['account_manager', 'access_style'])
.show(['account_type', 'access_level'])
.title('Create new user')
.buttons('Save')
.create('Add new user');Show and hide a field, based on user input:
$('input', editor.field('dept').node()).on('change', function () {
if (editor.field('dept').val() === 'Marketing') {
editor.show('marketing-section');
}
else {
editor.hide('marketing-section');
}
});