|
1371 | 1371 | * @param {array} parents the parents that we would want to aggregate onto
|
1372 | 1372 | */
|
1373 | 1373 | 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) { |
1375 | 1375 | row.treeNode.aggregations.forEach(function(aggregation) {
|
1376 | 1376 | // 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') { |
1378 | 1378 | var fieldValue = grid.getCellValue(row, aggregation.col);
|
1379 | 1379 | 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 | + } |
1381 | 1385 | }
|
1382 | 1386 | });
|
1383 | 1387 | }
|
1384 | 1388 |
|
1385 | 1389 | parents.forEach( function( parent, index ) {
|
1386 |
| - if ( parent.treeNode.aggregations ) { |
| 1390 | + if (parent.treeNode.aggregations) { |
1387 | 1391 | parent.treeNode.aggregations.forEach( function( aggregation ) {
|
1388 | 1392 | var fieldValue = grid.getCellValue(row, aggregation.col);
|
1389 | 1393 | var numValue = Number(fieldValue);
|
1390 | 1394 | aggregation.col.treeAggregationFn(aggregation, fieldValue, numValue, row);
|
1391 | 1395 |
|
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 | + } |
1394 | 1402 | }
|
1395 | 1403 | });
|
1396 | 1404 | }
|
|
0 commit comments