Skip to content

Commit 4a37231

Browse files
Portugal, Marcelomportuga
Portugal, Marcelo
authored andcommittedAug 4, 2018
fix(tree-base): agg: remove now works
Added fallback for when removing aggregations. fix #5682
1 parent 9eb9634 commit 4a37231

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
 

‎src/features/tree-base/js/tree-base.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1371,26 +1371,34 @@
13711371
* @param {array} parents the parents that we would want to aggregate onto
13721372
*/
13731373
aggregate: function( grid, row, parents ) {
1374-
if ( parents.length === 0 && row.treeNode && row.treeNode.aggregations ) {
1374+
if (parents.length === 0 && row.treeNode && row.treeNode.aggregations) {
13751375
row.treeNode.aggregations.forEach(function(aggregation) {
13761376
// Calculate aggregations for footer even if there are no grouped rows
1377-
if ( typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) {
1377+
if (typeof(aggregation.col.treeFooterAggregation) !== 'undefined') {
13781378
var fieldValue = grid.getCellValue(row, aggregation.col);
13791379
var numValue = Number(fieldValue);
1380-
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
1380+
if (aggregation.col.treeAggregationFn) {
1381+
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
1382+
} else {
1383+
aggregation.col.treeFooterAggregation.value = undefined;
1384+
}
13811385
}
13821386
});
13831387
}
13841388

13851389
parents.forEach( function( parent, index ) {
1386-
if ( parent.treeNode.aggregations ) {
1390+
if (parent.treeNode.aggregations) {
13871391
parent.treeNode.aggregations.forEach( function( aggregation ) {
13881392
var fieldValue = grid.getCellValue(row, aggregation.col);
13891393
var numValue = Number(fieldValue);
13901394
aggregation.col.treeAggregationFn(aggregation, fieldValue, numValue, row);
13911395

1392-
if ( index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) {
1393-
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
1396+
if (index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined') {
1397+
if (aggregation.col.treeAggregationFn) {
1398+
aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);
1399+
} else {
1400+
aggregation.col.treeFooterAggregation.value = undefined;
1401+
}
13941402
}
13951403
});
13961404
}

0 commit comments

Comments
 (0)
Please sign in to comment.