I am using AG Grid library in my angular project. I have 2 grids in a specific view in which I display Tree Data. When I click a row on one grid, I have to scroll down to a specific row in another grid. I am using the following code for this purpose:
this.gridApi?.forEachNodeAfterFilter((node) => {
if (selectedMappedRow?.id=== node.data.id) {
node.setSelected(true);
this.gridApi.ensureNodeVisible(node, 'middle');
}
});
This code works but if the parent of the row that i want to select has been collapsed by the user, the above code does not work. I tried to manually expand all the parent nodes of the selected node but still that did not work.
this.gridApi?.forEachNodeAfterFilter((node) => {
if (selectedMappedRow?.fragment === node.data.fragment) {
let parentNode = node.parent;
while (parentNode) {
parentNode.setExpanded(true);
parentNode = parentNode.parent;
}
node.setSelected(true);
this.gridApi.ensureNodeVisible(node, 'middle');
}
});
Can anyone tell me how to solve this problem.