You can manipulate with Tree items via the API of the selection object. It is possible to select an item, remove selection, and get the id or even the object of a selected Tree item.
Enabling/Disabling Selection objectâStarting from v7.0, you can activate selection of items via the enable() method of the selection object.
To disable selection of items in Tree, make use of the disable() method of the selection object:
tree.selection.disable();
Related sample: Tree. Disable / enable selection
note
To make the process of working with the selection of items more flexible, you can apply the related events of the Selection object.
Selecting an itemâTo select a particular Tree item, make use of the add() method of the selection object. As a parameter the method takes the id of an item.
const id = tree.selection.getId();
tree.selection.add("2");
Unselecting an itemâ
To remove selection from a selected item, apply the remove() method of the selection object. The method may take the id of an item as a parameter:
tree.selection.remove("2");
Starting from v7.0, the method unselects all previously selected items when calling without parameters:
Getting id of a selected itemâYou can get the id of the currently selected item with the getId() method of the selection object:
const selected = tree.selection.getId();
Getting object of a selected itemâ
It is also possible to get the object of a selected item using the getItem() method of the selection object:
const item = tree.selection.getItem();
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4