Sort Card View Data in Code
Server
To apply sorting to a column (or multiple columns), use one of the following methods.
- Set the column’s CardViewColumn.SortOrder property to ColumnSortOrder.Ascending or ColumnSortOrder.Descending.
- Call the column’s CardViewColumn.SortAscending or CardViewColumn.SortDescending method.
- Call ASPxCardView’s ASPxClientCardView.SortBy method.
The following sample code sorts data against the Contact Name column in ascending order.
((CardViewColumn)CardView.Columns["Contact Name"]).SortAscending();
The number of columns involved in sorting is returned by the ASPxGridBase.SortCount property. The column’s position among sorted columns is specified by the CardViewColumn.SortIndex property.
To remove sorting, do one of the following.
- Set the column’s CardViewColumn.SortOrder property to ColumnSortOrder.None.
- Call the column’s CardViewColumn.UnSort method.
- Set the CardViewColumn.SortIndex property to -1.
To clear sorting applied to ASPxCardView, call the ASPxGridBase.ClearSort method.
Client
Use the client-side ASPxClientCardView.SortBy 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 ASPxClientCardView.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
.