GridDataColumnSettings.SortMode Property
Gets or sets how the column’s (row’s for ASPxVerticalGrid) data is sorted when sorting is applied to it.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v18.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
ColumnSortMode | **Default** | One of the ColumnSortMode enumeration values. |
Available values:
Name | Description |
---|---|
Default | 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. |
Value | Sorts the column’s data by the column’s edit values (these are synchronized with the bound data source’s values). |
DisplayText | Sorts the column’s data by the column’s display text (the strings displayed within the column’s cells). |
Custom | 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. |
Property Paths
You can access this nested property as listed below:
Remarks
Find control-specific information (for ASPxGridView, ASPxCardView or ASPxVerticalGrid) in the sections below.
ASPxGridView
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 ASPxGridView.CustomColumnSort and ASPxGridView.CustomColumnGroup events.
Related Links
Example
The following example illustrates how to use the SortMode property.
WebForms approach:
Note
For a full example, see the ASPxGridView - Customization Dialog demo.
<dx:ASPxGridView ID="Grid" runat="server" DataSourceID="ProductsDataSource"
EnableRowsCache="false" Width="100%">
<Columns>
<dx:GridViewDataTextColumn FieldName="ProductName">
<Settings AutoFilterCondition="Contains" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataComboBoxColumn FieldName="CategoryID" Caption="Category Name" SortIndex="0" SortOrder="Ascending" AdaptivePriority="1">
<PropertiesComboBox DataSourceID="CategoriesDataSource" ValueField="CategoryID" TextField="CategoryName" ValueType="System.Int32" />
<Settings AllowHeaderFilter="True" AllowAutoFilter="False" SortMode="DisplayText" />
<SettingsHeaderFilter Mode="CheckedList" />
</dx:GridViewDataComboBoxColumn>
...
</Columns>
</dx:ASPxGridView>
MVC approach:
Note
For a full example, see the GridView - Customization Dialog demo.
@Html.DevExpress().GridView(settings => {
settings.Name = "GridView";
settings.SettingsCustomizationDialog.Enabled = true;
...
settings.Columns.Add(c => {
c.FieldName = "ProductName";
c.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
});
settings.Columns.Add(c => {
c.FieldName = "CategoryID";
c.Caption = "Category Name";
c.SortIndex = 0;
c.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
c.AdaptivePriority = 1;
c.Settings.AllowHeaderFilter = DefaultBoolean.True;
c.Settings.AllowAutoFilter = DefaultBoolean.False;
c.Settings.SortMode = DevExpress.XtraGrid.ColumnSortMode.DisplayText;
c.SettingsHeaderFilter.Mode = GridHeaderFilterMode.CheckedList;
c.EditorProperties().ComboBox(cb => {
cb.DataSource = NorthwindDataProvider.GetCategories();
cb.TextField = "CategoryName";
cb.ValueField = "CategoryID";
cb.ValueType = typeof(int);
});
});
}).Bind(Model).GetHtml()
ASPxCardView
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, set the SortMode property to Custom and handle the ASPxCardView.CustomColumnSort event.
Related Links
ASPxVerticalGrid
The SortMode property specifies the algorithm used to sort the row’s data (by display text, edit value or using a custom sorting algorithm).
To provide custom sorting, set the SortMode property to Custom and handle the ASPxVerticalGrid.CustomRowSort event.
Related Links
Vertical Grid - Getting Started