扩展组时如何在 ag-grid 的组列中显示值?

How to show values in the group column in ag-grid, when group is expanded?

我有以下数据:

[{ 'Year': 2016, Month: 'January, 'Other columns...' },
 { 'Year': 2016, Month: 'February, 'Other columns...' }]

我希望它按年份分组。但是,当组展开时,我不想为月份单独列,而是像这样重用组列:

我想autoGroupColumnDef是我需要的,我几乎达到了我想要的:

gridOptions: GridOptions = {
  suppressAggFuncInHeader: true,
  autoGroupColumnDef: {field: 'Month', headerName: '', cellRendererParams: { suppressCount: true}},
  groupIncludeTotalFooter: true,
};


columnDefs: ColDef[] = [
  {field: 'Year', hide: true, rowGroup: true },
  {field: 'Other Column1', aggFunc: 'sum'},
  {field: 'Other Column2', aggFunc: 'sum'},
];

see stackblitz example

但是,月份值仍然与年份对齐,而不是在年份下方。

这可以通过 CSS 轻松实现。

.ag-theme-balham .ag-ltr .ag-row-group-leaf-indent {
  margin-left: 0 !important;
}

看看link:StackBlitz