Skip to main content

getState()

gets current values/states of controls

getState(id?: string | number): string | boolean | object;

Parameters:

  • id: string | number - optional, the id of a Toolbar control

Returns:

Either a string with the value of the control, or a boolean value with the state of the control, or an object with IDs of controls and their values/states.

Example

const state1 = toolbar.getState("search"); 
// -> "toolbar"

const state2 = toolbar.getState();
// -> {"search":"toolbar","edit":true,"align":"right"}

Related sample: Toolbar. Get state

Starting from v7.0, the method can return the value/state of the control by its id:

const state1 = toolbar.getState("search"); // -> "toolbar"

const state2 = toolbar.getState("edit"); // -> true/false

If id of a control is not passed to the method, the method returns an object with IDs of controls and their values/states:

const state = toolbar.getState(); 
// -> {"search":"toolbar","edit":true,"align":"right"}

Change log:

The ability to pass the id parameter to the method is added in v7.0.