Back to Devexpress

GridColumn.SortIndex Property

maui-devexpress-dot-maui-dot-datagrid-dot-gridcolumn-53da713b.md

latest2.1 KB
Original Source

GridColumn.SortIndex Property

Gets or sets the column’s position among sorted columns. This is a bindable property.

Namespace : DevExpress.Maui.DataGrid

Assembly : DevExpress.Maui.DataGrid.dll

NuGet Package : DevExpress.Maui.DataGrid

Declaration

csharp
public int SortIndex { get; set; }

Property Value

TypeDescription
Int32

The zero-based column’s index among sorted columns. -1 if data is not sorted by this column.

|

Remarks

The grid allows data sorting by multiple columns if the DataGridView.SortMode property is set to GridSortMode.Multiple. Set the GridColumn.SortOrder property for each column to be sorted and specify their SortIndex to set the sort sequence.

Example

The following example sorts the Employee and Birth Date column data in ascending order:

xaml
<dxg:DataGridView SortMode="Multiple" ...>
    <dxg:DataGridView.Columns>
        <dxg:TemplateColumn FieldName="Name" 
                            x:Name="EmployeeNameColumn"
                            Caption="Employee" 
                            SortIndex="0" 
                            SortOrder="Ascending" 
                            SortMode="DisplayText">
            <!--...-->
        </dxg:TemplateColumn>
        <dxg:DateColumn FieldName="BirthDate" 
                        x:Name="BirthDateColumn" 
                        SortIndex="1" 
                        SortOrder="Ascending" 
                        SortMode="Value"/>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>

See Also

GridColumn Class

GridColumn Members

DevExpress.Maui.DataGrid Namespace