GridGroupRowCommandContext.GroupColumn Property
Returns the grouping column.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
Declaration
public IGridDataColumn GroupColumn { get; }
Property Value
| Type | Description |
|---|---|
| IGridDataColumn | A Grid data column. |
Remarks
The DevExpress Blazor Grid allows you to display context menus with predefined and custom commands. Use the ContextMenus property to activate context menus for specific Grid elements. Handle the CustomizeContextMenu event to modify the menu item collection. Use the Context event argument to identify the target Grid element and obtain contextual information.
When the target element is a group row, the Context property returns a GridGroupRowCommandContext object. Use the object’s GroupColumn property to access the grouping column.
Example
The following example adds custom Promote Group Level/Demote Group Level commands to the group row context menu:
@inject WeatherForecastService ForecastService
<DxGrid Data="@forecasts"
ShowGroupPanel="true"
ContextMenus="GridContextMenus.GroupRow"
CustomizeContextMenu="OnCustomizeContextMenu">
<Columns>
<DxGridSelectionColumn />
<DxGridDataColumn FieldName=@nameof(WeatherForecast.TemperatureC) Caption="Temp. (C)" GroupIndex="1" />
<DxGridDataColumn FieldName=@nameof(WeatherForecast.TemperatureF) Caption="Temp. (F)" />
<DxGridDataColumn FieldName=@nameof(WeatherForecast.Summary) Caption="Summary" GroupIndex="0" />
<DxGridDataColumn FieldName=@nameof(WeatherForecast.Date) DisplayFormat="dd/MM/yyyy" />
</Columns>
<GroupSummary>
<DxGridSummaryItem SummaryType="GridSummaryItemType.Count" FieldName="Date" FooterColumnName="Date" />
</GroupSummary>
</DxGrid>
@code {
private List<WeatherForecast>? forecasts;
protected override async Task OnInitializedAsync() {
forecasts = await ForecastService.GetForecastAsync();
}
void OnCustomizeContextMenu(GridCustomizeContextMenuEventArgs args) {
if (args.Context is GridGroupRowCommandContext groupRowContext) {
args.Items.AddCustomItem(0, "Promote Group Level", () => {
groupRowContext.Grid.BeginUpdate();
if (groupRowContext.Grid.GetRowLevel(groupRowContext.RowVisibleIndex) !=0)
groupRowContext.GroupColumn.GroupIndex--;
groupRowContext.Grid.EndUpdate();
});
args.Items.AddCustomItem(0, "Demote Group Level", () => {
groupRowContext.Grid.BeginUpdate();
var maxGroupLevel = groupRowContext.Grid.GetGroupCount();
if (groupRowContext.Grid.GetRowLevel(groupRowContext.RowVisibleIndex) != maxGroupLevel)
groupRowContext.GroupColumn.GroupIndex++;
groupRowContext.Grid.EndUpdate();
});
}
}
}