Filter Tree List Data in Code
This topic provides information on filtering ASPxTreeList data programmatically.
In code, you can apply filters to all or individual columns. To filter grid data by an individual column, use the following methods.
- The ASPxClientTreeList.AutoFilterByColumn method (Client Side)
- The ASPxTreeList.AutoFilterByColumn method (Server Side)
The TreeListDataColumn.AutoFilterBy method.
((TreeListDataColumn)ASPxTreeList2.Columns["Department"]).AutoFilterBy(String.Empty);
To clear filter settings for a single column, pass an empty string to the column’s TreeListDataColumn.AutoFilterBy method.
To provide complex filter criteria (filtering data by multiple columns), specify the filter expression and assign it to the ASPxTreeList.FilterExpression property.
ASPxTreeList.FilterExpression="End_Date > 2017-09-15";
Setting the ASPxTreeList.FilterExpression property to an empty string clears the filter expression applied to the ASPxTreeList.
ASPxTreeList2.FilterExpression = String.Empty;
Example
The following code applies a filter that selects orders where the Country is “USA” and the Unit Price is greater than “250”. The image below shows the result.
ASPxTreeList1.FilterExpression = "[Country] = 'USA' AND [UnitPrice] > 250";