The DevExpress Blazor Grid can calculate group summary values across all records in a group. You can use the DataColumnGroupRowTemplate property to specify custom content and appearance for summary rows.
The GroupRowContent.razor custom Razor component defines the template used for both group row content and group summaries aligned with their respective columns. Its internal structure is built with a standard HTML table layout.
This template is included with our Blazor Grid (DxGrid) component through the DataColumnGroupRowTemplate property. Row data is passed through the Context property to the GroupRowContent custom component. Row context allows you to access a Grid's instance. We use it to render the required column structure within the HTML table element, the group row, and group summary values. Visual styles for these elements are defined in the accompanying GroupRowContent.razor.css stylesheet.
<DataColumnGroupRowTemplate>
<GroupRowContent Context="context"></GroupRowContent>
</DataColumnGroupRowTemplate>The InitializeSummaryTable JavaScript function synchronizes template column width with individual Grid columns. It also attaches a ResizeObserver to the Grid to automatically update table column width whenever the Grid is resized. JavaScript functions are defined in the root component. They are invoked from the page's OnAfterRender lifecycle event using Blazor JS Interop.
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JS.InvokeVoidAsync("InitializeSummaryTable", ".myGrid");
}Our Blazor Grid’s LayoutAutoSaving event is used to handle Grid layout changes.
async Task OnLayoutAutoSaving(GridPersistentLayoutEventArgs e)
{
stateService.GridLayoutChanged = true;
}When the event fires, the custom component invokes the AdjustSummaryTable JavaScript function to ensure group row display is updated correctly.
- DxGrid Component
- DxGrid.GroupSummary Property
- DxGrid.DataColumnGroupRowTemplate Property
- GridDataColumnGroupRowTemplateContext Class
- DxGrid.LayoutAutoSaving Event
- Grid for Blazor - Customize cell appearance based on custom conditions
- Blazor Grid - How to display detail information using DxFormLayout
(you will be redirected to DevExpress.com to submit your response)
