UI网格分组自动扩展

ama*_*ter 3 expand grouping angular-ui-grid

有人知道如何自动扩展正在执行分组的UI网格吗?我需要网格打开并启动它完全展开.

他们的API和教程参考文献没有明确解释我的理解.

我的HTML div

<code>
&lt;div id="grid1" ui-grid="resultsGrid" class="myGrid" ui-grid-grouping&gt;&lt;/div&gt;
</code>
Run Code Online (Sandbox Code Playgroud)

我的Javascript

    
    $scope.resultsGrid = {
      ,columnDefs: [
      { field:'PhoneNum', name:'Phone'},
      { field:'Extension', name:'Extension'},
      { name:'FirstName'},
      { field:'DeptDesc', grouping: {groupPriority: 0}} 
      ]
    ,onRegisterApi: function(gridApi)
      {
      $scope.gridApi = gridApi;
      }
    }
    
    

Moh*_*ALI 6

你只需要添加

//expand all rows when loading the grid, otherwise it will only display the totals only
      $scope.gridApi.grid.registerDataChangeCallback(function() {
          $scope.gridApi.treeBase.expandAllRows();
        });
Run Code Online (Sandbox Code Playgroud)

在你的onRegisterApi: function(gridApi)应该像这样更新,onRegisterApi: function(gridApi)所以你的功能将是这样的

$scope.resultsGrid.onRegisterApi = function(gridApi) {       
      //set gridApi on scope
      $scope.gridApi = gridApi;

      //expand all rows when loading the grid, otherwise it will only display the totals only
      $scope.gridApi.grid.registerDataChangeCallback(function() {
          $scope.gridApi.treeBase.expandAllRows();
        });
    };
Run Code Online (Sandbox Code Playgroud)

或者你可以添加botton来扩展这个plunker中显示的数据