DxGridDataColumn.SortIndex Property

Specifies the column’s index among sorted columns.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll


public int SortIndex { get; set; }

Property Value

Type Description

The column’s index (zero-based) among sorted columns. -1 if the grid does not sort data by this column.


The SortIndex property allows you to sort grid data by an individual column in code. In this case, sorting is applied regardless of the DxGrid.AllowSort or DxGridDataColumn.AllowSort property value.

If you sort data by multiple columns, this property specifies the sort level. For instance, the grid first sorts data by a column with SortIndex = 0 and then by a column with SortIndex = 1. If you set this property to -1, data is not sorted by the corresponding column.

@using Microsoft.EntityFrameworkCore
@using Grid.Northwind
@inject NorthwindContext Northwind

<DxGrid Data="GridDataSource"
        <DxGridDataColumn FieldName="OrderDate"
                      SortIndex="1" />
        <DxGridDataColumn FieldName="Customer" />
        <DxGridDataColumn FieldName="Freight"
                      SortOrder="GridColumnSortOrder.Descending" />

@code {
    IGrid MyGrid;
    object GridDataSource { get; set; }

    protected override void OnInitialized() {
        GridDataSource = Northwind.Orders
            .Include(i => i.Customer)
            .Include(i => i.OrderDetails)
            .Include(i => i.ShipViaNavigation)

    void OnCustomizeCellDisplayText(GridCustomizeCellDisplayTextEventArgs e) {
        if (e.FieldName == "Customer") {
            var customer = (Customer)e.Value;
            e.DisplayText = $"{customer.CompanyName} ({customer.Country}, {customer.City})";

Grid - SortIndex

Run Demo: Grid - Sort Data


See Also