| Project owner: | Eugene Lazutkin |
|---|---|
| since: | 1.3 |
This class is the component of the form manager. It should be used together with \_Mixin.
The mixin provides commonly used methods to show/hide attached nodes (see controlled elements for more details) by modifying display property of node's style using "none" value to hide the node, and "" value to show it. It doesn't use any other display values.
This mixin is modeled after \_EnableMixin.
This section describes all public methods and properties of the dojox.form.manager._DisplayMixin class.
This method collects show/hide status information in a dictionary object as Boolean values (true means shown). It is modeled after \_valueMixin's gatherFromValues().
There are three ways to use this method:
var names = ["main", "opt"]; var state = fm.gatherDisplayState(names);Only supplied names will be collected.
var names = {main: 1, opt: 1}; var state = fm.gatherDisplayState(names);Only supplied names will be collected.
This form is especially useful when we already collected values, and want to collect their display state:
var names = ["main", "opt"]; var values = fm.gatherFormValues(names); // later in the code var state = fm.gatherDisplayState(values);
var state = fm.gatherDisplayState();
This method shows/hides attached nodes. It can take 0, 1 or 2 parameters described below, and returns the form manager itself for easy chaining.
There are three ways to use this method:
var names = ["main", "opt"], defaultState = true; fm.show(names, defaultState);All form elements with supplied names will be shown or hidden according to the value of defaultState (true means "show").
defaultState can be omitted. In this case it is assumed to be true:
var names = ["main", "opt"]; fm.show(names);The code above shows two form elements.
var state = {main: true, opt: false}; fm.enable(state);The example above shows "main" and hides "opt".
var defaultState = true; fm.show(defaultState);The code above shows all known attached nodes.
defaultState can be omitted. In this case it is assumed to be true:
fm.show();The code above shows all attached nodes.
This method is complimentary to show. Just like show it takes a state object but it always uses false (for "hide") as the default state. It can take 0, or 1 parameter described below, and returns the form manager itself for easy chaining.
There are three ways to use this method:
var names = ["main", "opt"]; fm.hide(names);All attached nodes with supplied names will be hidden.
var state = {main: true, opt: false}; fm.hide(state);The example above shows "main" and hides "opt".
fm.hide();
All three methods are designed to work together:
// collect the previous state of all attached nodes
var state = fm.gatherDisplayState();
// show the optional panel
fm.show(["opt"]);
// hide the main panel
fm.hide(["main"]);
// revert to the original state
fm.show(state);