In my treeview
component I'm loading more than 1000 nodes as a child node of one parent. Then on parent node's nodeChecked
event I'm looping through all 1000 child nodes and calling getTreeData()
method for getting all data of specific child node by passing child id. Now issue is, this process is taking much time and I'm facing performance issue. If tree has more than 1000 records getTreeData()
takes longer to return the result. I've checked documentation and found that there is no method other than getTreeData
which will return entire tree node's data. Is there any alternative of getTreeData()
method?
Asked
Active
Viewed 416 times
0

a.ak
- 659
- 2
- 12
- 26
1 Answers
0
We checked your query and would like to let you know that, the TreeView component fetches the data with feasible performance timing. In your scenario, the loop will be executed for 1000 items, which will then be executed for another 1000 times to fetch the tree data of corresponding node through getTreeData() method. This is the root cause of the reported scenario in your end. Since you are fetching the node details through nodeChecked event, instead of using getTreeData() method you can get the node details by using the event arguments as shown below.
public nodeChecked(args) {
var data = args.data;
console.log(data);
}
Sample: https://stackblitz.com/edit/angular-getnodedata-hzkwjl-hrxmop-kkn1ne-dl8ji8?file=app.component.ts

user15195016
- 26
- 1
-
Sample to get details using nodeChecked event: https://stackblitz.com/edit/angular-get-treenode?file=app.component.ts – keerthana Jun 09 '21 at 15:45
-
First Thank You for your reply. args.data key gives only specific data. If I add any custom key in my datasource then It will not return that. As in the given sample numberOfSubgroups is added but args.data not returning it. I need all child node's related data. – Patel Hetal Jun 09 '21 at 17:26
-
You can get the data of a particular node by passing the id of the selected node in the getTreeData method as demonstrated in the below code snippet, public nodeChecked(args) { var data = this.treeObj.getTreeData(args.data[0].id); console.log(data); } Sample: https://stackblitz.com/edit/angular-get-treenode-farkth?file=app.component.ts Can you please confirm, whether you need to get the details of all the TreeView nodes in the nodeChecked event or please elaborate on your use case requirement in detail? – keerthana Jun 10 '21 at 11:11
-
On parents node checked event I'm looping through all its child nodes and getting detail of each child node using getTreeData() method. But as I'm looping for 1000 child nodes it takes time. I need all detail of child node. So I can not use getNode() method here as it only returns specific detail. – Patel Hetal Jun 15 '21 at 03:57