1
votes

here's my demo plunker: http://plnkr.co/edit/Oqd1WHow01ssu43e I'm trying to improve the performance of grid for custom aggregation fuction custom aggregation function, In my codes, I had registered rowSelectionChanged for notifying grid to update data

onRegisterApi: function( gridApi ) {
      $scope.gridApi = gridApi;
      function updateGrid(option) {
        switch (option) {
          case 'column':
            $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
            break;
          case 'row':
            $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ROW);
            break;
          case 'edit':
            $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.EDIT);
            break;
          case 'options':
            $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
            break;
          default:
            $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL);
        }
      }
      $scope.debounceUpdateGrid =_.debounce(()=>updateGrid('column'),100);
      gridApi.selection.on.rowSelectionChanged($scope, function (row) {
        $scope.debounceUpdateGrid();
      });
      gridApi.selection.on.rowSelectionChangedBatch($scope, function (row) {
        updateGrid('column'); 
      });
    }

when I checked the selectAll header, the grid only run one time

gridApi.selection.on.rowSelectionChangedBatch($scope, function (row) {
        updateGrid('column'); 
      });

If I check a group header to select all children rows, the grid will run around children rows's length times

gridApi.selection.on.rowSelectionChanged($scope, function (row) {
        $scope.debounceUpdateGrid();
        // here debouceUpdate will prevent $scope.gridApi.core.notifyDataChange from being called many tiems which will be more costy or if there's other way for notify grid to update data (custom aggregation result/ selected rows's sum)
      });

Is there a way to improve grid performance when I check a parent group header to select hundreds children rows?

Thank in advance:)

1

1 Answers

0
votes

I've found a solution, here is the demo,