首页 > 解决方案 > 带角度 ui-grid 的大数据(特征分组选择)

问题描述

这是我的演示插件: http ://plnkr.co/edit/Oqd1WHow01ssu43e 我正在尝试提高网格的性能以实现自定义聚合功能 自定义聚合功能,在我的代码中,我已注册通rowSelectionChanged知网格以更新数据

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'); 
      });
    }

当我检查 selectAll 标题时,网格只运行一次

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

如果我检查组标题以选择所有子行,则网格将围绕子行的长度时间运行

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)
      });

当我检查父组标题以选择数百个子行时,有没有办法提高网格性能?

预先感谢:)

标签: angularjsangular-ui-grid

解决方案


我找到了解决方案,这里是demo


推荐阅读