2016-08-30 6 views
0

私は現在、集計からの合計が100であることを確認するために私の列のフッターを読もうとしています。しかし、グリッド関数からその値を取得する方法が見つかりません。たぶん私はドキュメントの機能を見逃していました。これを達成する方法はありますか、手動でグリッドをループして値を合計する必要がありますか?UI - グリッドの列フッターから合計値を読み取りますか?

答えて

1

列のフッターに集計を使用すると、列のすべての値の合計を自動的に表示できます。

あなたは列のインデックスを知っているとgridApiへの参照を持って提供し、フッターから値を取得するには

$scope.gridOptions = { 
    showGridFooter: true, 
    showColumnFooter: true, 
    enableFiltering: true, 
    columnDefs: [ 
     { field: 'name', width: '13%' }, 
     { field: 'address.street',aggregationType: uiGridConstants.aggregationTypes.sum, width: '13%' }, 
     { field: 'age', aggregationType: uiGridConstants.aggregationTypes.avg, aggregationHideLabel: true, width: '13%' }, 
     { name: 'ageMin', field: 'age', aggregationType: uiGridConstants.aggregationTypes.min, width: '13%', displayName: 'Age for min' }, 
     { name: 'ageMax', field: 'age', aggregationType: uiGridConstants.aggregationTypes.max, width: '13%', displayName: 'Age for max' }, 
     { name: 'customCellTemplate', field: 'age', width: '14%', footerCellTemplate: '<div class="ui-grid-cell-contents" style="background-color: Red;color: White">custom template</div>' }, 
     { name: 'registered', field: 'registered', width: '20%', cellFilter: 'date', footerCellFilter: 'date', aggregationType: uiGridConstants.aggregationTypes.max } 
    ], 
    data: data, 
    onRegisterApi: function(gridApi) { 
      $scope.gridApi = gridApi; 
    } 
}; 

http://plnkr.co/edit/nv1eJAIyD5xNDn8XI6L9?p=preview

以下のようなあなたのグリッドの設定を持つことができます。

$scope.getFooterValue = function() 
{ 
    console.log($scope.gridApi); 
    alert($scope.gridApi.grid.columns[2].getAggregationValue()); 
} 
+0

私はすでにこれをやっています。私がしたいことは、その集計の価値を取り、それを私のjavascriptのどこかで使用することです。 – dustyjuicebox

+0

はplnkrを更新しました。 gridApiへの参照を使用する必要があります。 – Kathir

関連する問題