Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxGridColumn.VisibleIndexChanged Event

Fires when the column’s visible index changes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[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);
    }
}

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

See Also