Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Collapse]ASP.NET Bootstrap Controls
 [Expand]Getting Started
 [Collapse]Grid View
  [Expand]Binding to Data
  [Expand]Data Representation Basics
  [Expand]Data Summaries
  [Expand]Filtering
  [Expand]Grouping
   Sorting
  [Expand]Focus and Navigation
  [Expand]Data Editing
  [Expand]Master-Detail Relationship
   Adaptivity
  [Expand]Templates
   Export Overview
   Data-Toggle Attribute
 [Expand]Card View
 [Expand]Charts
 [Expand]Data Editors
 [Expand]Site Navigation
 [Expand]Site Layout
 [Expand]Redistribution and Deployment
 [Expand]API Reference
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Sorting

Bootstrap Grid View allows its data to be sorted by an unlimited number of data columns.

To enable the sorting feature, set the column's GridDataColumnSettings.AllowSort property to True. If this property is set to Default, the column's behavior is controlled by Grid View's ASPxGridBehaviorSettings.AllowSort option.

Note

By default, Bootstrap Grid View does not sort a column if its data items do not implement the IComparable interface. To sort such columns, you can do one of the following.

Expanded Sorting at Runtime

End-users can sort data against a data column or change a column's sort order by clicking its header. The column's current sort order is indicated by the sort glyph displayed at the column header's right edge. If the column isn't sorted, the sort glyph is hidden.

If sorting isn't applied, clicking a column's header sorts data by its values in ascending order. If sorting is already applied to a column, subsequent clicks reverse the current sort order.

A regular click on a column header clears the sort settings on other columns. To preserve the existing sort settings of other columns, hold the SHIFT key down while clicking. This can be useful when sorting against multiple columns.

To clear a column's sorting, click its header while pressing the CTRL key.

Expanded Sorting in Code

Server

To apply sorting to a column(s), use one of the following methods.

The following sample code sorts data against the Department column in ascending order.

The number of columns involved in sorting is returned by the ASPxGridBase.SortCount property. A collection of sorted columns can be accessed via the ASPxGridView.GetSortedColumns method. The column's position among sorted columns is specified by the GridViewDataColumn.SortIndex property.

To remove sorting, do one of the following.

To clear sorting applied to Bootstrap Grid View, call the ASPxGridBase.ClearSort method.

Client

Use the ASPxClientGridView.SortBy client method to sort data by the values of the specified data column.

To prevent data from being sorted by the values of particular columns, handle the ASPxClientGridView.ColumnSorting client event. The processed client column is identified by the event parameter's column property. To cancel sorting, set the cancel property to true.

Note

If sorting is disabled for a column, rows cannot be grouped by this column.

Expanded See Also

How would you rate this topic?​​​​​​​