Data Selector Input State Variable Reference

Table of contents


Introduction

Data Selector Input state variables are a Selector Input state variable type that contains a set of state variable data with each option.

When a new option is selected by changing the state variable's value, the saved state associated with the new selection is restored.

The default component is the same as the Selector Input state variable. However, this is usually used in conjunction with a ListPage Component, which is rendered as a scrollable and editable list with a separate area from data entry that contains state variables. When a list item is selected, it restores that item's saved state variable state.

Item state

When a Data Selector Input is saved, the state variable value, the options, and the state variable data associated with each option are saved. The app code is expected to upgrade the saved state should the options or the set of associated state variables change when a new app version is started.

Data Selector Input state variables expect the associated page to determine when the current database entry which be updated when any of the associated state variables change. For example, it can happen immediately after the user changes any associated state variable or after the user hits a "Submit" button (or equivalent). The page is expected to call the updateOptionData() method whenever it's time to update the state variable state for the currently selected option.

In addition, the page must set up the list of state variables that are associated with each option by calling the sVars() method. Typically, this is done in the page's init() method.

Adding and deleting items

The save state variable data tracks the selector options. When the option list is changed by calling the options() method, the new list is scanned, any state variable data associated with options having the same value will be preserved allowing the displayed text to change. The state variable data for newly added option values is filled in from current values.

Child state variables

Constructor

Syntax

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

Parameters


Instance methods

Inherited methods

Note: The component() method returns a SelectorInputSvCmp.


getOptionData()

Syntax

getOptionData(value)
getOptionData()

Returns an object containing the saved data associated with the option that contains value. If value is omitted, the current dataSelectorInput value is used. The returned object is the same as returned by SV.getSavedState() for the list of saved state variables.

Return value

An object with a property corresponding to the ID of each state variable. The property value is the state variable value.


getSavedState()

Syntax

getSavedState()

Return an object containing the current state of the dataSelectorInput state variable, including the value, and the value, text, and the associated state variable data for each option.

Return value

An object containing the following properties:


isValidState()

Syntax

isValidState(state)

Returns true if state is valid for providing to the [setSavedState() method]. Checks that:

Return value

A Boolean.


options()

Syntax

options(opts, value)
options(opts)

Sets the state variable options according to the array of options 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 dflt parameter is not present in the updated options, then it is set to value if that value is present in the options or to the first option value if not present.

Parameters

Return value

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


restoreDataFromOption()

Syntax

restoreDataFromOption()

Restore the state variable values from the data associated with the currently selected option.


setSavedState()

Syntax

setSavedState(state)

Restore the state variable state from state. state is an object returned by the getSavedState() method. The following state is resored:

Parameters


sVars()

Syntax

sVars(...)
sVars()

If any arguments are present, it sets the list of state variables to saved with each option. This does not affect the previously saved in the current options list. If no arguments are provided it returns an array of the current associated state variables that will be captured when the updateOptionData() method is called.

The sVars() method returns the current array of state variables to be saved with each option.

Parameters

Each parameter specifies a single matching criteria. The meaning of each parameter depends on its type:

Return value

An array containing StateVar objects.


updateOptionData()

Syntax

updateOptionData(value)
updateOptionData()

If value is omitted, updateOptionData() updates the data associated with the currently selected option from the current value of the state variables in the list of state variables to be saved. If value is provided it updates the data associated with the option specified by value, if present in the option list.


Instance properties

Inherited properties


Component attributes

Inherited attributes