Skip to main content

DxGridColumn.VisibleIndexChanged Event

Fires when the column’s visible index changes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public EventCallback<int> VisibleIndexChanged { get; set; }

Parameters

Type Description
Int32

A new value of the VisibleIndex property.

Remarks

The VisibleIndex property allows you to define display order for Grid columns explicitly. Users can then reorder columns at runtime. Handle the VisibleIndexChanged event to respond to column position changes.

@inject WeatherForecastService ForecastService

<DxGrid Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" VisibleIndex="@CurrentIndex"
                          VisibleIndexChanged="OnVisibleIndexChanged" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
        <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
        <DxGridDataColumn FieldName="Forecast" />
        <DxGridDataColumn FieldName="CloudCover" />
    </Columns>
</DxGrid>

<div>@IndexInfo</div>

@code {
    object Data { get; set; }
    int CurrentIndex { get; set; }
    string IndexInfo { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast();
    }

    void OnVisibleIndexChanged(int newIndex) {
        CurrentIndex = newIndex;
        IndexInfo = "You moved the 'Date' column to position " + (newIndex + 1);
    }
}

Blazor Grid Column Visible Index Changed

Set DxGrid.AllowColumnReorder or DxGridColumn.AllowReorder property to false to prevent users from reordering columns.

See Also