@@ -143,24 +143,31 @@ function will stop working), and writes them to the console.
143
143
};
144
144
145
145
$scope.getAggregates = function() {
146
- var aggregateInfo = {};
147
- var lastState;
148
- $scope.gridApi.grid.renderContainers.body.visibleRowCache.forEach( function(row) {
149
- if( row.groupHeader ) {
150
- if( row.groupLevel === 0 ){
151
- // in the format "xxxxx (10)", we want the xxxx and the 10
152
- if( match = row.entity.state.match(/(.+) \((\d+)\)/) ){
153
- aggregateInfo[ match[1] ] = { stateTotal: match[2] };
154
- lastState = match[1];
155
- }
156
- } else if (row.groupLevel === 1){
157
- if( match = row.entity.gender.match(/(.+) \((\d+)\)/) ){
158
- aggregateInfo[ lastState ][ match[1] ] = match[2];
146
+ var aggregatesTree = [];
147
+ var gender
148
+
149
+ var recursiveExtract = function( treeChildren ) {
150
+ return treeChildren.map( function( node ) {
151
+ var newNode = {};
152
+ angular.forEach(node.row.entity, function( attributeCol ) {
153
+ if( typeof(attributeCol.groupVal) !== 'undefined' ) {
154
+ newNode.groupVal = attributeCol.groupVal;
155
+ newNode.aggVal = attributeCol.value;
159
156
}
157
+ });
158
+ newNode.otherAggregations = node.aggregations.map( function( aggregation ) {
159
+ return { colName: aggregation.col.name, value: aggregation.value, type: aggregation.type };
160
+ });
161
+ if( node.children ) {
162
+ newNode.children = recursiveExtract( node.children );
160
163
}
161
- }
162
- });
163
- console.log(aggregateInfo);
164
+ return newNode;
165
+ });
166
+ }
167
+
168
+ aggregatesTree = recursiveExtract( $scope.gridApi.grid.treeBase.tree );
169
+
170
+ console.log(aggregatesTree);
164
171
};
165
172
}])
166
173
.filter('mapGender', function() {
0 commit comments