Skip to main content

DxGrid.DataColumnGroupRowTemplate Property

Specifies a common template used to display all group rows in the Grid.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<GridDataColumnGroupRowTemplateContext> DataColumnGroupRowTemplate { get; set; }

Property Value

Type Description
RenderFragment<GridDataColumnGroupRowTemplateContext>

The template for all group rows.

Remarks

The DataColumnGroupRowTemplate allows you to specify custom content and appearance for all group rows in the Grid. To define a template for group rows of individual columns, use the DxGridDataColumn.GroupRowTemplate.

The DataColumnGroupRowTemplate accepts a GridDataColumnGroupRowTemplateContext object as the context parameter. You can use the parameter’s members to get information about the current group row (for instance, GroupValue, SummaryItems, DataColumn, and so on). You can also access the Grid object and use its members to obtain additional information about the Grid.

The following code snippet customizes all group rows displayed in the Grid. These rows contain the group field’s value and summary values that are highlighted in bold.

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="@Data"
        ShowGroupPanel="true">
    <Columns>
        <DxGridDataColumn FieldName="Country" GroupIndex="0" Width="200px" />
        <DxGridDataColumn FieldName="City" GroupIndex="1"/>
        <DxGridDataColumn FieldName="OrderDate" Width="200px" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" Width="120px" />
        <DxGridDataColumn FieldName="Quantity" Width="120px" />
    </Columns>
    <DataColumnGroupRowTemplate>
        <text>@context.ColumnCaption: @context.GroupValueDisplayText</text>
        @{
            var summaryItems = context.Grid.GetGroupSummaryItems();
            if (summaryItems.Any()) {
                <text> (</text>
                foreach (var i in summaryItems) {
                    if (i != summaryItems.First()) {
                        <text>, </text>
                    }
                    @context.Grid.GetGroupSummaryLabel(i, context.VisibleIndex)
                    <text>: </text>
                    <b>@context.Grid.GetGroupSummaryFormattedValue(i, context.VisibleIndex)</b>
                }
                <text>)</text>
            }
        }
    </DataColumnGroupRowTemplate>
    <GroupSummary>
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Count" FieldName="CompanyName" />
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Max" FieldName="OrderDate" />
    </GroupSummary>
</DxGrid>

@code {
    object Data { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = Northwind.Invoices
            .ToList();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

Blazor Grid Common Group Row Template

Run Demo: Grid - Group Row Template View Example: Grid - Select and Deselect All Rows in a Group

For more information, refer to the following topics:

See Also