angular-tree-component icon indicating copy to clipboard operation
angular-tree-component copied to clipboard

Get node by index

Open ottosson opened this issue 5 years ago • 0 comments

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!

ottosson avatar May 22 '19 15:05 ottosson