Skip to main content

getState()

gets the state of a tree

getState(): { [id: string]: { selected: number, open: boolean }};

Returns:

An object of key:value pairs, where key is the id of a tree item and value is an object which includes two properties:

  • selected: number - the status of a checkbox of an item:
    • 0 - unselected
    • 1 - selected
    • 2 - indeterminate (for the parent item, in case its children are partially checked)
  • open: boolean - checks whether a tree item is open (for folders with items)

Example

const treeState = tree.getState();
/* ->
{
books: {open: true, selected: 2},
mystery: {open: true, selected: 0},
fantasy: {open: undefined, selected: 0}
}
*/

Related sample: Tree. Getting Tree state