expanded(index, [expanded], [recursive])

Class: Tree.

Description:

Sets or gets the expand state of a specified item that has children. Items without children cannot be expanded. When setting expanded argument and index doesn't point to an item then just nothing will happen.

Parameters:

Name Type Default Description

index

Array.<number>

Index path of the item in question

[expanded]

boolean

Pass true or false to set the expand state, or omit to get current state.

[recursive]

boolean

false

Whether the specified expand state should be applied to all children items recursively. Default is false.

Returns:

If expanded argument is passed, then this Tree component is returned; otherwise current expand state is returned, or undefined if specified index in not valid.

Type: boolean | undefined | Tree

Examples:

Expand root node:

tree.expended([0], true);

Collapse item at specified index:

tree.expended([0, 2], false);

Check if item at specified index is expanded:

let expanded = tree.expended([0, 2]);