Skip to main content
All docs
V25.2
  • GridCustomizeContextMenuEventArgs.Grid Property

    Returns the Grid object.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    Declaration

    public IGrid Grid { get; }

    Property Value

    Type Description
    IGrid

    The Grid object.

    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.

    DevExpress Blazor Grid - Context Menus

    Run Demo: Context Menu

    Handle the CustomizeContextMenu event to modify the menu item collection. Use the Grid event argument to access the Grid and its extensive API.

    Example

    The following example adds custom Show Footer/Hide Footer commands to all context menus:

    @inject WeatherForecastService ForecastService
    
    <DxGrid Data="@Data" ContextMenus="GridContextMenus.All" CustomizeContextMenu="OnCustomizeContextMenu">
        <Columns>
            <DxGridDataColumn FieldName="Date" DisplayFormat="D" />
            <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
            <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
            <DxGridDataColumn FieldName="Forecast" />
            <DxGridDataColumn FieldName="CloudCover" />
        </Columns>
        <TotalSummary>
            <DxGridSummaryItem SummaryType="GridSummaryItemType.Count" FieldName="Date" />
        </TotalSummary>
    </DxGrid>
    
    @code {
        object Data { get; set; }
    
        protected override void OnInitialized() {
            Data = ForecastService.GetForecast();
        }
    
        void OnCustomizeContextMenu(GridCustomizeContextMenuEventArgs args) {
            var isFooterVisible = args.Grid.FooterDisplayMode != GridFooterDisplayMode.Never;
            string footerItemText = isFooterVisible ? "Hide Footer" : "Show Footer";
            var newState = isFooterVisible ? GridFooterDisplayMode.Never : GridFooterDisplayMode.Always;
            args.Items.AddCustomItem(0, footerItemText, () => {
                args.Grid.BeginUpdate();
                args.Grid.FooterDisplayMode = newState;
                args.Grid.EndUpdate();
            });
        }
    }
    
    See Also