[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Get Started With Data Grid and Views
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
     Sorting in Code
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)


This section provides information on sorting data in the Data Grid.

Expanded Sort Data

By default, end-users can sort data by any column, except for columns with MemoExEdit, ImageEdit and PictureEdit in-place editors. At runtime, click a column header once to sort data ascending. Consequent clicks will reverse the sort order. Sort glyph (up or down arrow) in column headers indicates the current sort order.

To sort data by a specific column end-users can also right-click this column's header and select "Sort Ascending" or "Sort Descending".

Related API

Expanded Multi-Column Sorting

The Data Grid discards the currently applied sorting when end-users click column headers, and keeps it when users sort data through header context menus. Thus, to sort data by multiple columns, end-users should either utilize header context menus or hold the Shift key down when clicking column headers. In the figure below, data is first sorted ascending by the "Customer ID" field and then descending by order dates.

Expanded Clear Sorting

To remove data sorting by a specific column, end-users should click this column's header with the Ctrl key pressed. Alternatively, a user can right-click this header and select "Clear Sorting". To simultaneously remove sorting by all columns, select "Clear All Sorting" instead.

Related API

  • GridOptionsCustomization.AllowSort - prevents end-users from unsorting data by Ctrl+clicking column headers and disables the "Clear Sorting" option for all grid columns.

  • OptionsColumn.AllowSort - prevents end-users from unsorting data by Ctrl+clicking this column's header and disables the "Clear Sorting" option for this column.

  • GridView.PopupMenuShowing - allows you to manually modify or remove context menu items, with which end-users can change sorting. The code below changes the "Clear All Sorting" item behavior so that end-users will be unable to remove the predefined sorting by the "Order Date" column.

Expanded Sort Groups by Summary Values

The Data Grid can sort groups according to these groups' summary values. See the Summaries article for the details.

Expanded Sort Modes

By default, columns with LookUpEdit and ImageComboBoxEdit in-place editors sort their data by editor's display values. Other columns sort their data by the editor's edit values. Use the GridColumn.SortMode property to change this sorting mode.

In the figure below, a column with ImageComboBoxEdit is forced to sort items by priority, from low to high. To do so, the GridColumn.SortMode must be changed to ColumnSortMode.Value. Otherwise, items are sorted alphabetically by their display values.

Is this topic helpful?​​​​​​​