Class: Variant

Variant

The Variant control is a single  control that can be used to represent the following controls: Text, Masked Text, Single Select, Date, Decimal, Integer  A Variant control provides the following configuration properties in Process Designer:

Behavior

Auto Select Control: Enables the variant to auto-select the used control based on the type of data boolean
Control Index Expression: This expression should return a 0-based index corresponding to the control to be shown by default when not using Auto selection string

Events

On Load:
Description: This event is triggered when the Variant control is loaded.
Example:
me.reset()
On Change:
Description: This event is triggered when there is a change detected.
Example:
console.log(me.getValue())
Articles
Variant

new Variant()

This constructor is never used explicitly.

Extends

Members

Methods

Add/replace CSS class(es) for this control
Name Type Description
name string CSS class name(s) to add to the control. Separate class names by a space if more than one class.
replaced string optional CSS class name(s) to be replaced by the first argument. Separate class names by a space if more than one class.
Example
Button.addClass("green");

getCurrentChildView()(){CoachView}

This method returns the reference to the Coach View currently shown by the Variant control
Returns:
Type Description
CoachView
Example
me.getCurrentChildView().setValid(false, "Validation error");
Retrieve bound data associated this view/control. Only works for views/controls with bound data.
Returns:
Type Description
Object Value of bound data. undefined if the view has no data binding.
Example
var dec1 = MyDecimal.getData();

getDisplayedType(){string}

Get descriptive string representing the type of control the variant is currently displaying or "none" if no control is currently displayed
Returns:
Type Description
string

getType(){string}

Get descriptive string representing the type of control
Returns:
Type Description
string

getValue(){integer|string|boolean|decimal|object}

This method returns the current value that is shown by the Variant control. It can return any primitive types or object.
Returns:
Type Description
integer | string | boolean | decimal | object
Hide this view/control
Name Type Description
collapseFlag boolean Set to true to collapse the view (equivalent to a view setting of "NONE")
Example
MyView.hide();
Indicates bound status of control.
Returns:
Type Description
boolean True if the control is bound to coach data.
Checks if the view is enabled or not
Returns:
Type Description
boolean Enabled status
Example
var enabled = MyView.isEnabled();
Checks if control label is visible
Returns:
Type Description
boolean Label visibility status
Example
var labelVisible = MyView.isLabelVisible();
Returns the valid status as last set by the setValid() method.
Returns:
Type Description
boolean Validity status. true if setValid(false, ...) was never called
Example
var valid = MyView.isValid();
Checks whether or not view is visible
Returns:
Type Description
boolean Visibility status
Example
var visible = MyView.isVisible();
Propagates value change of control up through parent views
Name Type Description
event Event Value change event (usually an onchange event)
Returns:
Type Description
boolean True if a formula update was triggered on the control's parent, otherwise false
Example
MyView.propagateUp(event);
Only for formula-enabled views!
Explicitly triggers the re-evaluation of the formula for this view (if a formula has been specified). If the view is not formula-enabled, recalculate() does nothing.
Example
Text1.recalculate(); //If the formula for Text1 is: new Date().toString(), Text1 is updated to the current date/time

reset()

This method resets the variant control which causes NO control to display
Example
me.reset();
Set/update bound data associated this view/control. Only works for views/controls with bound data.
Name Type Description
value Object Value of bound data. The type of this parameter must match the type of the bound data.
Example
MyView.setData("TEST"); //Updates bound data to the string 'TEST'
Enable/disable this view/control
Name Type Description
enabled boolean Enabled/read-only flag (true to enable view, false to disable/make read-only)
required boolean Enable/disable required field flag for control
Example
MyView.setEnabled(false); //Make MyView read-only
Show/hide the label of this view/control
Name Type Description
visible boolean Label visibility flag (true to show view label, false to hide)
Example
MyView.setLabelVisible(false);
Flag this view/control as valid or invalid
Name Type Description
valid boolean Valid/invalid flag (true to set view valid, false to make it invalid - which typically shows the view with "invalid" styling and indicator)
errorText string Validation error text to show on the invalid-styled view
Example
MyView.setValid(false, "Please fix your data entry"); //Make MyView invalid

setValue(val)

This method allows to programmatically set the value for the control
Name Type Description
val integer | string | boolean | decimal | object the value
Example
me.setValue(132);
Show/hide this view/control
Name Type Description
visible boolean Visibility flag (true to show view, false to hide)
collapse boolean Set to true to collapse the control space when visible is set to false.
Examples
MyView.setVisible(false, false); //Equivalent to MyView.hide()
MyView.setVisible(false, true); // Sets visibility to "None"
Show this view/control
Example
MyView.show();

showControl(idx)

This method allows you to programmatically set the index of the control to be used
Name Type Description
idx integer the index of that variant control that you want to show
Example
me.showControl(0);
Broadcasts the expression trigger for the specified view
Name Type Default Description
phase int bpmext.ui.PHASE_NORMAL optional The phase we are currently in
Example
MyView.triggerFormulaUpdates();