Angular Data GridRow Grouping - Multiple Group Columns

Enterprise

Display the group structure with one group column representing each level of row grouping.

Enabling Multiple Group Columns

The example above demonstrates that both country and year are grouped. One group column is used to display the group value cells for each column that was grouped.

Multiple Group Columns can be enabled by setting the groupDisplayType grid option to "multipleColumns" as shown below:

<ag-grid-angular
    [groupDisplayType]="groupDisplayType"
    /* other grid options ... */ />

this.groupDisplayType = 'multipleColumns';

Configuration

The columns are added to the grid when row grouping is present, and can be configured via the autoGroupColumnDef grid option.

The example above uses the configuration demonstrated below to change the column's header name and apply a minimum width. It also Configures the Group Cell Component using the cellRendererParams option to remove the count from each row group.

<ag-grid-angular
    [autoGroupColumnDef]="autoGroupColumnDef"
    [rowSelection]="rowSelection"
    /* other grid options ... */ />

this.autoGroupColumnDef = {
    headerValueGetter: params => `${params.colDef.headerName} Group Column`,
    minWidth: 220,
    cellRendererParams: {
        suppressCount: true,
    }
};
this.rowSelection = {
    mode: 'singleRow',
    checkboxLocation: 'autoGroupColumn',
};

Display the Parent Group Value

The group hierarchy is represented by relative location to the parent. When scrolling through the grid it can become harder to keep track of the parent group value.

Setting the grid property showOpenedGroup to true will show the value of the parent group inside the group column.

The example above demonstrates the following configuration to show the parent group value inside the group column:

<ag-grid-angular
    [showOpenedGroup]="showOpenedGroup"
    /* other grid options ... */ />

this.showOpenedGroup = true;

Cell Renderer

The column uses the agGroupCellRenderer component to display the group information, as well as the chevron control for expanding and collapsing rows. The renderer also embeds the grouped columns renderer and displays this inside of the group cell.

This can be configured with several Group Renderer Properties using the autoGroupColumnDef property cellRendererParams. The example below removes the row count and enables checkboxes for row selection.

The example above demonstrates the following configuration:

<ag-grid-angular
    [columnDefs]="columnDefs"
    [autoGroupColumnDef]="autoGroupColumnDef"
    [rowSelection]="rowSelection"
    /* other grid options ... */ />

this.columnDefs = [
    { field: 'total', rowGroup: true, cellRenderer: CustomMedalCellRenderer },
    // ... other column definitions
];
this.autoGroupColumnDef = {
    cellRendererParams: {
        suppressCount: true,
    }
};
this.rowSelection = {
    mode: 'singleRow',
    checkboxLocation: 'autoGroupColumn',
};

Configurable Options

suppressPadding
boolean
Set to true to not include any padding (indentation) in the child rows.
suppressDoubleClickExpand
boolean
Set to true to suppress expand on double click.
suppressEnterExpand
boolean
Set to true to suppress expand on ↵ Enter
totalValueGetter
string | TotalValueGetterFunc
The value getter for the total row text. Can be a function or expression.
suppressCount
boolean
If true, count is not displayed beside the name.
innerRenderer
any
The renderer to use for inside the cell (after grouping functions are added)
innerRendererParams
any
Additional params to customise to the innerRenderer.
innerRendererSelector
Function
Callback to enable different innerRenderers to be used based of value of params.

Custom Inner Renderer

When using the group cell renderer, the agGroupCellRenderer component will inherit the grouped columns renderer and display this inside of the group cell, adjacent to any configured checkboxes, cell count, and the expand/collapse chevron control.

This inner renderer can be overridden with a Custom Cell Component by setting the innerRenderer and innerRendererParams properties on the cellRendererParams configuration.

The example above uses the following configuration to provide a custom inner renderer to the group column:

<ag-grid-angular
    [autoGroupColumnDef]="autoGroupColumnDef"
    /* other grid options ... */ />

this.autoGroupColumnDef = {
    cellRendererParams: {
        innerRenderer: CustomMedalCellRenderer,
    },
};

Custom Cell Renderer

The Group Cell Renderer can be entirely replaced with a Custom Cell Component by setting the cellRenderer property on the autoGroupColumnDef configuration.

It is also possible to Determine Cell Renderers Dynamically.

Filtering

To enable filters on the group column, set the filter property of the autoGroupColumnDef to 'agGroupColumnFilter'. This configuration will cause the group column to inherit the the filter from the column it is representing.

The example above demonstrates the following configuration to inherit the filter from the grouped column:

<ag-grid-angular
    [autoGroupColumnDef]="autoGroupColumnDef"
    /* other grid options ... */ />

this.autoGroupColumnDef = {
    filter: 'agGroupColumnFilter',
    floatingFilter: true,
};

Hiding Expanded Parent Rows

Expanded rows can be configured to disappear when they are open, instead moving the group cell renderer into the first child row. To enable this feature set the groupHideOpenParents grid option to true.

When groupHideOpenParents is enabled the grid no longer sticks expanded group rows to the top of the viewport.

The example above demonstrates the following configuration to hide open parents:

<ag-grid-angular
    [groupHideOpenParents]="groupHideOpenParents"
    /* other grid options ... */ />

this.groupHideOpenParents = true;

Next Up

Continue to the next section to learn about the Group Rows display type.