ColumnBase.SortMode Property

Gets or sets how the column’s data is sorted when sorting is applied to it. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v21.1.Core.dll


public ColumnSortMode SortMode { get; set; }

Property Value

Type Default Description


A ColumnSortMode enumeration value that specifies the sort mode.

Available values:

Name Description

Sorts the column’s data according to the type of the editor assigned to the column.

The Default option is equivalent to DisplayText for columns that use LookUpEdit, ImageComboBoxEdit and HypertextLabel (RepositoryItemHypertextLabel) in-place editors.

The Default option is equivalent to Value for other columns. Note that for certain editors (TextEdit, ComboBoxEdit, etc) the edit values match the display values.


Sorts the column’s data by the column’s edit values (these are synchronized with the bound data source’s values).


Sorts the column’s data by the column’s display text (the strings displayed within the column’s cells).


Enables custom sorting of a column’s data. To implement custom sorting, handle the ColumnView.CustomColumnSort event in the GridControl, and the TreeList.CompareNodeValues event in the TreeList.

In the GridControl, the Custom mode also enables custom grouping of rows when grouping is applied against the current column. To implement custom grouping, handle the GridView.CustomColumnGroup event.


The SortMode property specifies the algorithm used to sort the column’s data (by display text, edit value or using a custom sorting algorithm).

To provide custom sorting and/or grouping, set the SortMode property to ‘Custom’ and handle the GridControl.CustomColumnSort and GridControl.CustomColumnGroup events.

Example: How to Implement Custom Sorting

This example demonstrates how to implement custom sorting in the GridControl. Handle the GridControl.CustomColumnSort event, assign your custom sorted list to the e.Result property and set the e.Handled property to true.

View Example

<Window x:Class="CustomSorting.Window1" 
        Title="Custom Column Sort" Height="300" Width="300" >
        <dxg:GridControl ItemsSource="{Binding Items}" Grid.Row="1" 
                <dxg:GridColumn FieldName="Day" GroupIndex="0" SortMode="Custom" />
                <dxg:GridColumn FieldName="Employee" />
                <dxg:TableView />
using System.Windows;
using System.Collections.Generic;
using DevExpress.Xpf.Grid;
using CustomSorting;
using System;

namespace CustomSorting {

    public partial class Window1 : Window {
        public Window1() {
            DataContext = new SchedulerData();

        void OnCustomColumnSort(object sender, CustomColumnSortEventArgs e) {
            if (e.Column.FieldName == "Day") {
                int dayIndex1 = GetDayIndex((string)e.Value1);
                int dayIndex2 = GetDayIndex((string)e.Value2);
                e.Result = dayIndex1.CompareTo(dayIndex2);
                e.Handled = true;

        int GetDayIndex(string day) {
            return (int)Enum.Parse(typeof(DayOfWeek), day);
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CustomSorting {
    public class SchedulerData {
        const int daysInWeek = 7;
        string[] employees = new string[] { 
            "Jane", "Martin", "John", "Jack", "Amanda", "Carmen", "Wins", "Todd", "Ashley" };
        Random rnd = new Random();
        public List<SchedulerItem> Items { get; set; }
        public SchedulerData() {
            Items = new List<SchedulerItem>();
        void GenerateRandomData() {
            for (int i = 0; i < daysInWeek; i++) {
                int e1 = rnd.Next(employees.Length - 1);
                int e2 = e1 + 1;
                string day = DateTime.Today.AddDays(i).DayOfWeek.ToString();
                Items.Add(new SchedulerItem() { Day = day, Employee = employees[e1] });
                Items.Add(new SchedulerItem() { Day = day, Employee = employees[e2] });

    public class SchedulerItem {
        public string Day { get; set; }
        public string Employee { get; set; }
See Also