2016-09-19 16 views
1

私はアグリゲート機能を使用していますが、agg:console.Afterでエラーが表示されないようにしてください:他の列にアグリゲート機能を適用できません。angularjs - 角度UIグリッドバグ - アグリ:削除が機能していない

check this image for error例外TypeError:aggregation.col.treeAggregationFnは

関数ではありません
var app = angular.module('app', ['ngAnimate', 'ngTouch', 'ui.grid', 'ui.grid.grouping' ]); 

    app.controller('MainCtrl', ['$scope', '$http', '$interval', 'uiGridGroupingConstants', function ($scope, $http, $interval, uiGridGroupingConstants) { 
     $scope.gridOptions = { 
     enableFiltering: true, 
     treeRowHeaderAlwaysVisible: false, 
     columnDefs: [ 
      { name: 'name', width: '30%' }, 
      { name: 'gender', grouping: { groupPriority: 1 }, sort: { priority: 1, direction: 'asc' }, width: '20%', cellFilter: 'mapGender' }, 
      { name: 'age', treeAggregationType: uiGridGroupingConstants.aggregation.MAX, width: '20%' }, 
      { name: 'company', width: '25%' }, 
      { name: 'registered', width: '40%', cellFilter: 'date', type: 'date' }, 
      { name: 'state', grouping: { groupPriority: 0 }, sort: { priority: 0, direction: 'desc' }, width: '35%', cellTemplate: '<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">{{COL_FIELD CUSTOM_FILTERS}}</div></div>' }, 
      { name: 'balance',cellTemplate:'<a>Balance</a>', width: '25%', cellFilter: 'currency', treeAggregationType: uiGridGroupingConstants.aggregation.AVG, customTreeAggregationFinalizerFn: function(aggregation) { 
      aggregation.rendered = ''; 
      } } 
     ], 
     onRegisterApi: function(gridApi) { 
      $scope.gridApi = gridApi; 
     } 
     }; 

     $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json') 
     .success(function(data) { 
      for (var i = 0; i < data.length; i++){ 
      var registeredDate = new Date(data[i].registered); 
      data[i].state = data[i].address.state; 
      data[i].gender = data[i].gender === 'male' ? 1: 2; 
      data[i].balance = Number(data[i].balance.slice(1).replace(/,/,'')); 
      data[i].registered = new Date(registeredDate.getFullYear(), registeredDate.getMonth(), 1) 
      } 
      delete data[2].age; 
      $scope.gridOptions.data = data; 
     }); 

     $scope.expandAll = function(){ 
     $scope.gridApi.treeBase.expandAllRows(); 
     }; 

     $scope.toggleRow = function(rowNum){ 
     $scope.gridApi.treeBase.toggleRowTreeState($scope.gridApi.grid.renderContainers.body.visibleRowCache[rowNum]); 
     }; 

     $scope.changeGrouping = function() { 
     $scope.gridApi.grouping.clearGrouping(); 
     $scope.gridApi.grouping.groupColumn('age'); 
     $scope.gridApi.grouping.aggregateColumn('state', uiGridGroupingConstants.aggregation.COUNT); 
     }; 

     $scope.getAggregates = function() { 
     var aggregatesTree = []; 
     var gender 

     var recursiveExtract = function(treeChildren) { 
      return treeChildren.map(function(node) { 
      var newNode = {}; 
      angular.forEach(node.row.entity, function(attributeCol) { 
       if(typeof(attributeCol.groupVal) !== 'undefined') { 
       newNode.groupVal = attributeCol.groupVal; 
       newNode.aggVal = attributeCol.value; 
       } 
      }); 
      newNode.otherAggregations = node.aggregations.map(function(aggregation) { 
       return { colName: aggregation.col.name, value: aggregation.value, type: aggregation.type }; 
      }); 
      if(node.children) { 
       newNode.children = recursiveExtract(node.children); 
      } 
      return newNode; 
      }); 
     } 

     aggregatesTree = recursiveExtract($scope.gridApi.grid.treeBase.tree); 

     console.log(aggregatesTree); 
     }; 
    }]) 
    .filter('mapGender', function() { 
     var genderHash = { 
     1: 'male', 
     2: 'female' 
     }; 

     return function(input) { 
     var result; 
     var match; 
     if (!input){ 
      return ''; 
     } else if (result = genderHash[input]) { 
      return result; 
     } else if ((match = input.match(/(.+)(\(\d+\))/)) && (result = genderHash[match[1]])) { 
      return result + match[2]; 
     } else { 
      return input; 
     } 
     }; 
    }); 

Here is plunkr 
https://plnkr.co/edit/lTkddSNhfLPHQfuldWfs?p=preview 

答えて

0

これは、UIグリッドのバグのようです。

解決するまで回避するには、グループ解除されている列に対してフッター集計を手動で無効にすることをお勧めします。次のコードを使用してください。

column.treeFooterAggregation = undefined; 
column.aggregationType = undefined; 
column.aggregationValue = undefined; 
+0

グループ化されたすべての列を特定し、この操作を実行する方法はありますか。私は、ユーザーがデータ分析の一環として複数の列をグループ化し、すべてのグループを削除してリストア/リセットしたいグリッドを持っています。 clearGrouping関数が呼び出されると、上記のエラーが発生します。 –

+0

イベントを使用し、treeAggregation.typeプロパティを使用して、以下のように集約が削除されているかどうかを確認します。gridAPI.grouping.on.aggregationChanged(scope、function(column){ if(column.treeAggregation.type){ column.treeFooterAggregation =未定義;未定義 column.aggregationType =; column.aggregationValue =不定;}}) – varmabsrk

関連する問題