angular-tree-component
angular-tree-component copied to clipboard
Get node by index
Is it possible to get a node by it's index in the tree?
I want to iterate nodes from one index to another and set them to active (I'm implementing shift selecting). My tree is only one level deep, i.e. just a list of items.
for (let i = this.previousSelectedNode.index + 1; i <= currentSelectedNode.index; i++) {
// here my thought is to do something like this: tree.getNodeByIndex(i).setIsActive(...);
}
I've tried to use this approach, but it is really slow...
for (let i = this.previousSelectedNode.index + 1; i <= currentSelectedNode.index; i++) {
const nodei = tree.getNodeBy((x: TreeNode) => {
return x.index === i;
});
}
Any better suggestions? Thanks!