简体   繁体   English

Ag-grid 分组:如果组包含单个元素,则避免显示组行

[英]Ag-grid grouping: avoid showing group row if group contains a single element

I would like not to show group header row if group contains only one element, showing the row itself instead.如果组只包含一个元素,我不想显示组标题行,而是显示行本身。 I tried to do it via CSS, but there isn't a way to hide the header row evaluating how many consecutive siblings of level 1 rows there are after group header row (sorry for mindblowing explanation).我试图通过 CSS 来做到这一点,但没有办法隐藏标题行,以评估在组标题行之后有多少级别 1 行的连续兄弟姐妹(对不起,令人费解的解释)。

I would like to not "hack" it with jQuery or Javascript, is it possible?我不想用 jQuery 或 Javascript “破解”它,这可能吗? If I'm forced to do that, can you suggest me the safest way?如果我被迫这样做,你能告诉我最安全的方法吗?

在 ag-grid 的最新版本中,他们引入了groupRemoveSingleChildren属性来完成此操作

You just need to set the value of the group column to null or undefined , then it will not be grouped.您只需要将 group 列的值设置为nullundefined ,则不会对其进行分组。 Referring to the section on the documentation about unbalanced groups参考关于不平衡组的文档部分

Unbalanced Groups不平衡组

If there are rows containing null or undefined values for the column that is being grouped then these rows will not be grouped.如果要分组的列存在包含空值或未定义值的行,则不会对这些行进行分组。 We refer to this scenario as Unbalanced Groups in that there is a mix of groups and rows as siblings.我们将此场景称为不平衡组,因为将组和行混合为同级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM