Skip to content

Commit

Permalink
fix(tree-base): agg: remove now works
Browse files Browse the repository at this point in the history
Added fallback for when removing aggregations.

fix #5682
  • Loading branch information
Portugal, Marcelo authored and mportuga committed Aug 4, 2018
1 parent 9eb9634 commit 4a37231
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/features/tree-base/js/tree-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1371,26 +1371,34 @@
* @param {array} parents the parents that we would want to aggregate onto
*/
aggregate: function( grid, row, parents ) {
if ( parents.length === 0 && row.treeNode && row.treeNode.aggregations ) {
if (parents.length === 0 && row.treeNode && row.treeNode.aggregations) {
row.treeNode.aggregations.forEach(function(aggregation) {
// Calculate aggregations for footer even if there are no grouped rows
if ( typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) {
if (typeof(aggregation.col.treeFooterAggregation) !== 'undefined') {
var fieldValue = grid.getCellValue(row, aggregation.col);
var numValue = Number(fieldValue);
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
if (aggregation.col.treeAggregationFn) {
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
} else {
aggregation.col.treeFooterAggregation.value = undefined;
}
}
});
}

parents.forEach( function( parent, index ) {
if ( parent.treeNode.aggregations ) {
if (parent.treeNode.aggregations) {
parent.treeNode.aggregations.forEach( function( aggregation ) {
var fieldValue = grid.getCellValue(row, aggregation.col);
var numValue = Number(fieldValue);
aggregation.col.treeAggregationFn(aggregation, fieldValue, numValue, row);

if ( index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) {
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
if (index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined') {
if (aggregation.col.treeAggregationFn) {
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
} else {
aggregation.col.treeFooterAggregation.value = undefined;
}
}
});
}
Expand Down

0 comments on commit 4a37231

Please sign in to comment.