Skip to main content
All docs
V25.2
  • GridDataRowCommandContext.RowVisibleIndex Property

    Returns the visible index of the target row.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    Declaration

    public int RowVisibleIndex { get; }

    Property Value

    Type Description
    Int32

    A row visible index.

    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 data row cell, the Context property returns a GridDataRowCommandContext object. Use the object’s RowVisibleIndex property to obtain the target row’s visible index.

    Example

    The following code snippet adds a custom Delete command to the row context menu:

    @inject WeatherForecastService ForecastService
    
    <DxGrid Data="@forecasts"
            DataItemDeleting="OnDataItemDeleting"
            ContextMenus="GridContextMenus.DataRow"
            CustomizeContextMenu="OnCustomizeContextMenu">
        <Columns>
            <DxGridSelectionColumn />
            <DxGridDataColumn FieldName=@nameof(WeatherForecast.TemperatureC) Caption="Temp. (C)" />
            <DxGridDataColumn FieldName=@nameof(WeatherForecast.TemperatureF) Caption="Temp. (F)" />
            <DxGridDataColumn FieldName=@nameof(WeatherForecast.Summary) Caption="Summary" />
            <DxGridDataColumn FieldName=@nameof(WeatherForecast.Date) DisplayFormat="dd/MM/yyyy" />
        </Columns>
    </DxGrid>
    
    @code {
        private List<WeatherForecast>? forecasts;
    
        protected override async Task OnInitializedAsync() {
            forecasts = await ForecastService.GetForecastAsync();
            summaries = ForecastService.Summaries;
        }
        async Task OnDataItemDeleting(GridDataItemDeletingEventArgs e) {
            if (e.DataItem != null)
                await ForecastService.Remove((WeatherForecast)e.DataItem);
        }
        void OnCustomizeContextMenu(GridCustomizeContextMenuEventArgs args) {
            if (args.Context is GridDataRowCommandContext rowContext) {
                args.Items.AddCustomItem("Delete", () => {
                    args.Grid.ShowRowDeleteConfirmation(rowContext.RowVisibleIndex);
                });
            }
        }
    }
    
    See Also