- Home
- Forum
- Angular - EJ 2
- Programatically expand tree grid using PrimaryKey
Programatically expand tree grid using PrimaryKey
I have a tree which has this column defined:
<e-column field='functionalHierarchyId' textAlign='Left' [isPrimaryKey]='true' [visible]='false' [showInColumnChooser]='false'>
this.treegrid.expand(hierarchyId)
I can use hierarchyId to change cell value, ie:
this.treegrid.setCellValue(hierarchyId, 'column name ', 'new value');
Sample: https://stackblitz.com/edit/angular-f167875?file=app.component.ts
API documentation,
https://ej2.syncfusion.com/angular/documentation/api/treegrid/#getrows
https://ej2.syncfusion.com/angular/documentation/api/treegrid/#expandrow
https://ej2.syncfusion.com/angular/documentation/api/grid#getrowindexbyprimarykey
Jagadesh Ram
Thanks, but this solution does not work for nodes which are not displayed. In your example we see only 3 rows
What if I want to expand row with id 14 from this initial state?
In your sample, please change
1 to 14, like that:
treegrid.getRows()[treegrid.grid.getRowIndexByPrimaryKey(14)]
it throws errors.
Jagadesh Ram
expandAtLevel will expand all nodes on that level (regardless if they are in the branch with item with id 14, or not) , I do not want that.
So, in other words, there is no easy/simple way to expand a node which is not yet rendered (as the node 14 in the example).
Technically, I would need to find all parents of node with id 14, and then expand each of them?
Seems like an obvious missing feature here.
Jagadesh Ram
- 5 Replies
- 2 Participants
- Marked answer
-
MS Michal Szkudlarek
- Aug 5, 2021 01:21 PM UTC
- Aug 10, 2021 12:41 PM UTC