在NG-网与外部按钮清除分组 [英] Clear grouping in ng-grid with external button
问题描述
我有一个纳克网格数据被按类别分组,如下所示:
I have a ng-grid with data that is grouped by category, as shown below:
$scope.gridOptions = {
columnDefs: [
{field: 'cat', displayName: 'Category'},
{field: 'name', displayName: 'Name'},
{field: 'val', displayName: 'Value'}
],
data: 'myData',
groups: ['cat']
}
我希望能够取消组中的一个按钮,NG-网格外部的数据。我不想显示该组面板(通过 $ scope.gridOptions.showGroupPanel:真正的
),它提供了一个X来清除分组
I would like to be able to un-group the data in the ng-grid externally with a button. I do not want to display the group panel (via $scope.gridOptions.showGroupPanel: true
), which provides an 'X' to clear the grouping.
我曾尝试执行上的外部按钮点击没有成功时,以下内容:
I have tried executing the following when clicking on the external button without any success:
-
$ scope.gridOptions.groups = [];
-
$ scope.gridOptions.groups.length = 0
$scope.gridOptions.groups = [];
$scope.gridOptions.groups.length = 0
我如何能清除分组有什么建议?最后,我想是能够对分组切换的按钮开/关;但是,清除分组似乎是一个良好的开端。感谢您的帮助!
Any suggestions on how I can clear the grouping? Ultimately I would like to be able to make the grouping toggle on/off with the button; however, clearing the grouping seems like a good first step. Thanks for your help!
下面是一个小提琴
推荐答案
有在源$ C $ C无证功能编程设置组。你可以简单的:
There is an undocumented function in the source code for programmatically setting groups. You can simply:
gridOptions.groupBy(columnFieldKey)
不幸的是,我一直没能超过一列在一个时间来找到一个方法来群,编程。
Unfortunately, I haven't been able to find a way to group by more than one column at a time, programmatically.
这篇关于在NG-网与外部按钮清除分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!