selected(index, [selected])

Class: Tree.

Description:

Sets or get a whether item or items at specified index or array o indexes are selected. This adds or removes items to/from current selection instead of replacing current selection like selection() method does. If "selected" argument is supplied, it will select or deselect specified items.

Parameters:

Name Type Description

index

Array.<number> | Array.<Array.<number>>

Index path of one item as array, or multiple items as array of arrays. When getting selection status, only first item is used.

[selected]

boolean

If supplied, it will indicate if specified items should be selected or not.

Returns:

If selected arguments is passed, this Tree component is returned; otherwise a selection status of first specified item is returned, or undefined if index doesn't point to an item.

Type: boolean | Tree

Examples:

Add one item to current selection:

tree.selected([0,2], true);

Add two items to current selection:

tree.selected([[0,3], [0,4]], true);

Deselect one item:

tree.selected([0,3], false);

Check if one item is selected:

let selected = tree.selected([0,4]); // -> true