Sort Tree List Data in Code
Server-Side
To apply sorting to a column(s), use one of the following methods:
- Set the column’s TreeListDataColumn.SortOrder property;
- Use the ASPxTreeList.SortBy method.
The following sample code sorts data against the Budget column in ascending order:
ASPxTreeList1.SortBy((TreeListDataColumn) ASPxTreeList1.Columns["Budget"], DevExpress.Data.ColumnSortOrder.Ascending);
The number of columns involved in sorting is returned by the ASPxTreeList.SortCount property. The column’s position among sorted columns is specified by the TreeListDataColumn.SortIndex property.
To remove sorting, do one of the following:
- Set the column’s TreeListDataColumn.SortOrder property to ColumnSortOrder.None;
- Call the column’s TreeListDataColumn.Unsort method;
- Set the column’s TreeListDataColumn.SortIndex property to -1.
To clear sorting applied to the ASPxTreeList, use the ASPxTreeList.ClearSort method.
Client-Side
Use the client ASPxClientTreeList.SortBy method to sort data by the values of the specified data column.