DxGridDataColumn.GroupRowTemplate Property

Specifies a template used to display group rows when the Grid is grouped by this column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

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

Property Value

Type Description
RenderFragment<GridDataColumnGroupRowTemplateContext>

The template for the column’s group rows.

Remarks

The GroupRowTemplate allows you to specify custom content and appearance for group rows when the Grid is grouped by this column. To define a common template for all group rows in the Grid, use the DxGrid.DataColumnGroupRowTemplate.

The GroupRowTemplate 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 example below customizes group rows displayed when Grid data is grouped by the Country column. Group rows contain the Country field value and summary values highlighted in bold.

@using Grid.Northwind
@inject NorthwindContext Northwind

<DxGrid Data="@Data"
        ShowGroupPanel="true">
    <Columns>
        <DxGridDataColumn FieldName="Country" GroupIndex="0">
            <GroupRowTemplate>
                <text>@context.DataColumn.FieldName: @context.GroupValue</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>
                    }
                }
            </GroupRowTemplate>
        </DxGridDataColumn>
        <DxGridDataColumn FieldName="City" />
        <DxGridDataColumn FieldName="OrderDate"/>
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
        <DxGridDataColumn FieldName="Quantity" />
    </Columns>
    <GroupSummary>
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Count" FieldName="Country" />
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Max" FieldName="OrderDate" />
    </GroupSummary>
</DxGrid>

@code {
    object Data { get; set; }

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

Blazor Grid Group Row Template

Run Demo: Grid - Group Row Template

Implements

See Also