这是一个老问题,但我遇到了完全相同的问题,所以我在这里给出我的解决方案:
我已经在aggregateTemplate中复制了单元格模板,然后对其进行了调整以显示箭头,并调用了一个函数来计算聚合值(例如,我只是复制第一行的值,对值的求和、最小值或最大值可以在列定义)
groupTemplate=
'<div ng-style="{\'top\':row.offsetTop+\'px\'}" class="{{row.aggClass()}}"></div>'
+'<div ng-click="row.toggleExpand()" ng-style="{ \'cursor\': row.cursor ,\'top\':row.offsetTop+\'px\'}" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell ngCellGroup {{col.cellClass}}">'
+'<div class="ngVerticalBar" ng-style="{height: rowHeight}" ng-class="{ ngVerticalBarVisible: !$last }"> </div>'
+'<div >{{aggFc(row,col) }}</div>'
+'</div>';
$scope.aggFc=function(rowAgg,col){
var row=rowAgg.children[0];
if(row.entity[col.field] && col.cellFilter){
console.log("'"+row.entity[col.field]+"' |" +col.cellFilter);
return $scope.$eval("'"+row.entity[col.field]+"' |" +col.cellFilter);
}
return row.entity[col.field]
};
$scope.yourGrid =
{
data: '...',
enableCellSelection: false,
enableRowSelection: true,
aggregateTemplate:groupTemplate,
...
我认为可以通过调整受您提供的链接启发的“$scope.aggFc”函数来使用此解决方案(如何在 ng-grid 中使用分组设置聚合)