Custom TemplatesOpen
Customize grouped headers, grouped cells, and grouped footer rows with public directives.
Use public group header and footer templates with a realistic transaction dataset.
This example groups transactions by account type and status, then uses template directives to show clearer grouped summaries inside the grid.
Use these guides when grouping needs to work together with the rest of the grid workflow.
ngbDatagridGroupHeaderTemplate customizes the main grouped field/value row. Here it turns the banking dataset into a more readable operational summary by showing the active group, record count, and total grouped amount.
ngbDatagridGroupHeaderColumnTemplate="field" renders inside the grouped row cell for a specific column. This example uses the amount column to show the current grouped total without replacing the built-in label cell.
Turn on [groupable]="{ showFooter: true }" and use ngbDatagridGroupFooterTemplate="field" for audit-style footer content. The same grouped rows render the footer automatically.
Loading interactive DataGrid example…
| API | Type | Usage |
|---|---|---|
ngbDatagridGroupHeaderTemplate | directive | Customizes the main grouped field/value row and receives `field`, `value`, `count`, `level`, `items`, and `aggregates`. |
ngbDatagridGroupHeaderColumnTemplate="field" | directive | Renders inside the grouped row cell for a specific column. |
ngbDatagridGroupFooterTemplate="field" | directive | Renders inside the grouped footer row cell for a specific column when footers are enabled. |
[groupable] | boolean | NgbDataGridGroupingSettings | Use an object to enable grouped footer rows with `showFooter`. |
showFooter is enabled on [groupable]. <ngb-datagrid
[data]="transactions"
[columns]="columns"
[groupable]="{ showFooter: true }"
[group]="group">
<ng-template
ngbDatagridGroupHeaderTemplate
let-field="field"
let-value="value"
let-count="count"
let-aggregates="aggregates">
{{ field }}: {{ value }} ({{ count }} transactions)
Volume {{ formatAmount(aggregates.amount.sum) }}
</ng-template>
<ng-template
ngbDatagridGroupHeaderColumnTemplate="amount"
let-aggregates="aggregates">
Running total {{ formatAmount(aggregates.amount.sum) }}
</ng-template>
<ng-template
ngbDatagridGroupFooterTemplate="amount"
let-aggregates="aggregates">
Footer total {{ formatAmount(aggregates.amount.sum) }} • Count {{ aggregates.amount.count }}
</ng-template>
</ngb-datagrid>
Move between the overview, templates, aggregates, and sticky grouped row guides without losing context.
Start with local and manual grouping, shared state, and the base grouped grid flow.
Customize grouped headers, grouped cells, and grouped footer rows with public directives.
Add grouped totals, counts, averages, and min or max values to real grouped rows.
Keep grouped context pinned while scrolling through large grouped result sets.