如何设置聚集在NG-电网分组 [英] How to set aggregation with grouping in ng-grid

查看:166
本文介绍了如何设置聚集在NG-电网分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要看到每个组总计(或一般的聚合函数)在网格中。

I want to see totals (or generally any aggregation function) for each group in a grid.

此请求和封闭方式发行完成: https://开头github上。 COM /角度的UI / NG网/问题/ 95 (但遗憾的是没有任何例子)。

This was requested and closed as done in issue: https://github.com/angular-ui/ng-grid/issues/95 (but unfortunately without any example).

我能够重新定义默认模板的https://github.com/angular-ui/ng-grid/blob/master/src/templates/aggregateTemplate.html通过 aggregateTemplate 配置选项。但我不知道如何正确地扩展它。

I am able to redefine default template https://github.com/angular-ui/ng-grid/blob/master/src/templates/aggregateTemplate.html by aggregateTemplate config option. But I don't know how to extend it properly.

这个模板在NG-电网范围评估和我不知道如何触发我的自定义聚合功能。我想创建一个类似的功能'''totalChildren'''(从的 https://github.com/angular-ui/ng-grid/blob/master/src/classes/aggregate.js

This template is evaluating in ng-grid scope and I don't know how to trigger my custom aggregation function. I want to create similar function as '''totalChildren''' (from https://github.com/angular-ui/ng-grid/blob/master/src/classes/aggregate.js )

任何想法?

推荐答案

我找到了答案:<一href=\"https://github.com/angular-ui/ng-grid/issues/290\">https://github.com/angular-ui/ng-grid/issues/290

有关这里completenes是我aggredate函数的例子:

For a completenes here is an example of my aggredate function:

function WorkLoadCtrl($scope, Issue, $routeParams, HttpCache) {
  $scope.issues = Issue.jql_search({jql: $routeParams.jql});

  $scope.aggFC = function (row) {
    var res = 0;

    var calculateChildren = function(cur) {
      var res = 0;
      var remaining;
      angular.forEach(cur.children, function(a) {
        remaining = a.getProperty('fields.timetracking.remainingEstimateSeconds');
        if (remaining) { res += remaining; }
      });
      return res;
    };

    var calculateAggChildren = function(cur) {
      var res = 0;
      res += calculateChildren(cur);
      angular.forEach(cur.aggChildren, function(a) {
        res += calculateAggChildren(a);
      });
      return res;
    };

    return (calculateAggChildren(row) / 3600).toFixed(2);
  }

  $scope.mySelections = [];
  $scope.gridOptions = {
    data: 'issues.issues',
    columnDefs: [
      {field:'key', displayName:'key'},
      {field:'fields.assignee.name', displayName:'Assignee'},
      {field:'fields.status.name', displayName:'Status'},
      {field:'fields.summary', displayName:'Summary'},
      {field:'fields.timetracking.remainingEstimate', displayName:'Remaining'},
    ],
    showFooter: true,
    showGroupPanel: true,
    enablePinning: true,
    enableColumnResize: true,
    enableColumnReordering: true,
    showColumnMenu: true,
    showFilter: true,
    //jqueryUIDraggable: true, bug: when used grouping stop work, but column reordering start to work:(
    selectedItems: $scope.mySelections,
    multiSelect: false,
    aggregateTemplate: '<div ng-click="row.toggleExpand()" ng-style="rowStyle(row)" class="ngAggregate"> <span class="ngAggregateText">{{row.label CUSTOM_FILTERS}} (count: {{row.totalChildren()}} {{AggItemsLabel}} Remaining: {{aggFC(row)}})</span> <div class="{{row.aggClass()}}"></div> </div>'
  };
}

这篇关于如何设置聚集在NG-电网分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆