Reputation: 1445
How can we get the data of all rows in a grouped column in Angular UI Grid?
For example, in the official Grouping Tutorial, how to get all the company names in the 'Company' column.
I was able to get the aggregated value of grouped row by using the following code:
for (var i = 0, l = $scope.gridRows.length; i<l; i += 1){
console.log($scope.gridRows[i].treeNode.aggregations[COLUMN_INDEX].value);
}
But doesn't work for the 'Company' column, since their is no aggregate value for that column, and what I want is all the company's names.
Thank you in advance for your time.
Upvotes: 1
Views: 3624
Reputation: 6650
The key knowledge here is that $scope.gridApi.grid.treeBase.tree
holds the rendered tree, and the structure of that tree is described in http://ui-grid.info/docs/#/api/ui.grid.treeBase.grid:treeBase
What I think you want to do is to walk that tree and extract the information you want.
So really you want to navigate that tree pulling out row.entity.company
. What I'm not clear on is why that would make sense - presumably you actually want to get at the specific companies under a given tree node, or the companies that are currently visible.
If you want the companies that are visible, you could check row.visible
as you walk the tree. If you want those under a specific node, you need a way to know which node you want. If you have a gridRow that you're trying to extract for, you can then use row.treeNode.children
to get at the subset of the tree that is under that specific row.
Upvotes: 2