DataGridHtmlGroupRowDecorationEventArgs<T>.GroupFieldName Property

Specifies a data source field’s name the processed group column is bound to.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public string GroupFieldName { get; }

Property Value

Type Description
String

A string that specifies a data source field’s name.

Remarks

Use the GroupFieldName property to access the group column’s data source field name. To obtain the value of the corresponding group column that is displayed within the processed group row, use the GroupKey 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