我正在使用ui-grid
并且我正在对数据进行分组,我需要获取组头和计数器。我怎样才能获得这些价值观?
这是网格的示例
$scope.gridOptions = {
enableFiltering: false,
enableColumnResize: true,
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
},
columnDefs: [
{ field: 'month',enableHiding: false, grouping: { groupPriority: 0 }, sort: { priority: 0, direction: 'desc' }},
{ field: 'facility',enableHiding: false,grouping: { groupPriority: 1 }, sort: { priority: 1, direction: 'asc' }},
...
{ field: 'categorymanager',enableHiding: false, displayName:'CM', grouping:{ groupPriority: 2 }, sort: { priority: 2, direction: 'asc' }},
]
};
答案 0 :(得分:0)
您可以为cellTemplate
编写自定义colDef
来获取值。例如,如果您可以将模板定义为:
let monthTemplate = '<div><div ng-if="!col.grouping || col.grouping.groupPriority === undefined || col.grouping.groupPriority === null || ' +
'( row.groupHeader && col.grouping.groupPriority === row.treeLevel )" class="ui-grid-cell-contents" ' +
'title="TOOLTIP">{{grid.appScope.getValue(COL_FIELD, row.treeNode.children )}}</div></div>';
然后将您的方法定义为:
$scope.getValue = function(item, treeRowEntity){
//item will hold month value
//iterate over treerowentity array and get values
//for example, if column required was facility
treeRowEntity[0].row.entity.facility
};