Selector Input State Variable Reference

Table of contents


Introduction

Selector Input state variables represent an input that allows the user to select from a series of options.

By default, the selector renders as a popup list of options for the user to select. The currently selected option is highlighted. The selector can also render as a set of radio buttons by specifying the radio attribute. The radio buttons can be horizontal or vertical, and the text labels can be on either side for both orientations by specifying one of the following attributes:

The options are not saved when a Selector Input is saved to storage. Only the selector value is saved. It is expected that the app code will reestablish the current options and upgrade the saved values as required.

Dynamic selectors

A Selector Input's state variable options can be static. If so, the isStatic property is true. Any attempt to change the options of a static selector will cause an assertion failure. Additionally, the isValid method will return false if the value does not match an available option.

A Selector Input's options can be changed if the isStatic property is false. The selector input can have any value except undefined, NaN, or an Error instance, and it will still be valid because the correct options might be set later. This is especially important when the application state is restored at startup before model execution sets the options.

The isStatic property is set by default if options are provided during construction. If no options are provided, or if the provided options array is empty, it is set to false. If info.isStatic is specified during construction, it overrides the default setting. This allows the app to filter a provided info.options array later. The isStatic property can also be modified dynamically after initialization.

Child state variables

Selector Input state variables maintain a public child state variable that can be referred to using the subname options (e.g., myPage_mySelector_options). The child state variable's value is an array of options objects containing the following properties:

The child state variable can be used to determine when the state variable options change (as opposed to the state variable value).

Constructor

Syntax

ctl.createPage({
	...,
	stateVarInfo:[
		{type:'selectorInput', ...},
	],
})

Parameters


Instance methods

Inherited methods

Note: The component() method returns a SelectorInputSvCmp.

findOption()

Syntax

findOption(value)

Returns an option object with the value.

Parameters

Return value

An object with the following properties:


fmtVal()

Syntax

fmtVal()

Returns the displayed text for the current state variable value.

Return value

A String.


hasOption()

Syntax

hasOption(value)

Returns true if the value exists in the options.

Parameters

Return value

A Boolean.


isValid()

Syntax

isValid(value)

If value is present, returns true if value is present in the options or if the isStatic property is true and the value is not undefined, NaN, or an instance of Error. If value is not present, the currently selected value is used.

Parameters

Return value

A Boolean.


options()

Syntax

options()
options(opts)
options(opts, value)

Sets or gets the state variable options. If opts is not present, the current options array is returned. Otherwise, the options are set according to the array in opts. If value is present, then the state variable value is set to value after the options in opts are set. If the state variable's isStatic attribute is true, then setting options is disallowed and will cause an assertion failure.

If the state variable's dflt attribute value is not present in the updated options, then it is set to value, if present, or to the first option value, if not present.

Parameters

Return value

An array of option objects, each containing the following properties:


optionTexts()

Return the list of option texts.

Syntax

optionTexts()

Return value

An array of option text strings.


optionValues()

Return the list of option values.

Syntax

optionValues()

Return value

An array of option options values.


Instance properties

Inherited properties


isSelector (read only)

Always true for selectorInput.

Value

A Boolean.


isStatic

Set to true if the options cannot be modified.

Value

A Boolean.


text (read only)

The option text associated with the current state variable value.

Value

A String.


Component attributes

Inherited attributes


DOM element properties