Skip to content

About

Customize the content and appearance of Grid's summary rows.

Topics

Resources

Stars

0 stars

Watchers

30 watching

Forks

Latest commit

 

History

64 Commits

Folders and files

Repository files navigation

DevExpress Blazor Grid - Customize Group Summaries

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.

Custom Group Summaries

Implementation Details

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.

Files to Review

Documentation

More Examples

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Customize the content and appearance of Grid's summary rows.

Topics

Resources

Stars

0 stars

Watchers

30 watching

Forks

Used by

Contributors

Languages