如何在一行上禁用行组扩展功能? [英] How to disable row group expand functionality on one row?
问题描述
在没有任何特定解决方案的情况下在SO中进行了大量搜索后,我不得不提出这个问题.我想要的是在单个组行上隐藏行组图标.如下图所示,我有一个只有一条记录的组行,该记录已显示在顶行中.我想隐藏那条记录上的折叠图标.仅当组行多于一个时显示折叠/展开图标.
参考
我正在使用以下版本的 AG-Grid Angular (v9)
@ag-grid-community/core":^25.3.0",@ag-grid-enterprise/row-grouping":^26.0.0",@ag-grid-enterprise/server-side-row-model":^25.3.0",ag-grid-angular":^25.3.0",ag-grid-community":^25.3.0",
这是我的代码:
this.rowModelType = 'serverSide';this.serverSideStoreType = '部分';this.cacheBlockSize = 20;this.gridOptions = {行数据:this.loanlist,columnDefs: this.generateColumns(),getNodeChildDetails:函数(rowItem){如果(rowItem.orderCount > 1){返回 {扩展:真实}} 别的 {返回空;}}}
问题是 getNodeChildDetails
不可访问.浏览器控制台向我显示以下警告,而我上面的代码不起作用.
使用 autoGroupColumnDef
上的 cellRendererSelector
很容易实现.您可以指定是显示默认的 agGroupCellRenderer
还是简单地返回另一个渲染器(或者,只返回 null
):
this.autoGroupColumnDef = {cellRendererSelector: (params) =>{if (params.value == '美国') {返回空;} 别的 {返回 {组件:'agGroupCellRenderer',};}},};
在下面的示例中,我们禁用了美国行的行组扩展功能.
在以下plunkr中查看此实现.
After a lot of searches in SO without any particular solution, I am compelled to ask this question. What I want is to hide a row group icon on a single group row. Like in the below picture I have a group row that has only one record, which is already shown in the top row. I want to hide that collapse icon on that single record. Only collapse/expand icon shown when group rows are more than one.
For reference see AG-Grid Master-Detail Section, here they specify which rows to expand. Same functionality I needed here.
I'm using the below versions of AG-Grid Angular (v9)
"@ag-grid-community/core": "^25.3.0",
"@ag-grid-enterprise/row-grouping": "^26.0.0",
"@ag-grid-enterprise/server-side-row-model": "^25.3.0",
"ag-grid-angular": "^25.3.0",
"ag-grid-community": "^25.3.0",
Here is my code:
this.rowModelType = 'serverSide';
this.serverSideStoreType = 'partial';
this.cacheBlockSize = 20;
this.gridOptions = {
rowData: this.loanlist,
columnDefs: this.generateColumns(),
getNodeChildDetails: function(rowItem) {
if (rowItem.orderCount > 1) {
return {
expanded: true
}
} else {
return null;
}
}
}
The issue is the getNodeChildDetails
is not accessible. Browser console showing me the below warning and my above code is not working.
This is simple to achieve using a cellRendererSelector
on the autoGroupColumnDef
. You can specify whether to show the default agGroupCellRenderer
or simply return another renderer (or, just return null
):
this.autoGroupColumnDef = {
cellRendererSelector: (params) => {
if (params.value == 'United States') {
return null;
} else {
return {
component: 'agGroupCellRenderer',
};
}
},
};
In the example below, we are disabling the row group expand functionality on the United States row.
See this implemented in the following plunkr.
这篇关于如何在一行上禁用行组扩展功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!