DataGridHtmlGroupRowDecorationEventArgs<T>.GroupKey Property

A group column value that corresponds to the processed row.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public object GroupKey { get; }

Property Value

Type Description
Object

An object that stores the value of a group column.

Remarks

Use the GroupKey property to access the group value that is displayed within the processed group row. To obtain the group column’s data source field name, use the GroupFieldName property.

DataGrid GroupFieldName GroupKey

The code below uses the HtmlRowDecoration event to decorate groups that contain the selected row.

<DxDataGrid @ref="@grid" 
            Data="@Vacancies"
            ShowPager="true"
            ShowGroupPanel="true"
            HtmlRowDecoration="@OnHtmlRowDecoration"
            SingleSelectedDataRowChanged="@OnSelectionChanged">
    <DxDataGridColumn Field="@nameof(Vacancy.Id)" Width="70px" AllowGroup="false"></DxDataGridColumn>
    <DxDataGridColumn Field="@nameof(Vacancy.Description)"></DxDataGridColumn>
    <DxDataGridComboBoxColumn Field="@nameof(Vacancy.Region)" Data="@VacancyRepository.Regions" GroupIndex="0"></DxDataGridComboBoxColumn>
    <DxDataGridColumn Field="@nameof(Vacancy.City)" GroupIndex="1"></DxDataGridColumn>
</DxDataGrid>

@code {
    IEnumerable<Vacancy> Vacancies;
    DxDataGrid<Vacancy> grid;

    void OnHtmlRowDecoration(DataGridHtmlRowDecorationEventArgs<Vacancy> eventArgs) { 
        if (eventArgs is DataGridHtmlGroupRowDecorationEventArgs<Vacancy> groupEventArgs)
            if (grid.SingleSelectedDataRow != null) {
                if (groupEventArgs.GroupFieldName == "Region" && (string)groupEventArgs.GroupKey == grid.SingleSelectedDataRow.Region)
                    groupEventArgs.CssClass += " table-primary";
                if (groupEventArgs.GroupFieldName == "City" && (string)groupEventArgs.GroupKey == grid.SingleSelectedDataRow.City)
                    groupEventArgs.CssClass += " table-secondary";
            }
    }

    void OnSelectionChanged(Vacancy selectedVacancy) {
        grid.Refresh();
    }
}

DataGrid GroupField Breadcrumbs

See Also