gpt4 book ai didi

grouping - UI网格分组自动扩展

转载 作者:行者123 更新时间:2023-12-02 07:02:51 25 4
gpt4 key购买 nike

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

他们的 API 和教程引用没有足够明确地解释让我理解。

我的 HTML div

<code>
&lt;div id="grid1" ui-grid="resultsGrid" class="myGrid" ui-grid-grouping&gt;&lt;/div&gt;
</code>

我的 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;
}
}

最佳答案

您只需添加

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

在您的 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();
});
};

或者您可以添加按钮来扩展数据,如this plunker所示

关于grouping - UI网格分组自动扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30405814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com