Skip to content

Commit 315961b

Browse files
authored
docs(treelist): provide sort expression examples
1 parent 1b41a78 commit 315961b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

controls/treelist/functionality/sorting.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,45 @@ Due to the self-referencing nature of the control, the sorting takes effect "per
4141
| **AllowNaturalSort** |Enables or disables the "natural" sort mode where the items are ordered in the way they came from the data source.|
4242
| **AllowSorting** |Enables the sorting functionality in RadTreeList.|
4343
| **SortExpressions** |SortExpressions collection. Contains the expressions that are applied to the control.|
44+
45+
46+
Example 1: Declarative Approach of setting the SortExpressions
47+
48+
````ASPX
49+
<telerik:RadTreeList ID="RadTreeList1" runat="server" DataSourceID="SqlDataSource1" AllowSorting="True" ...>
50+
<SortExpressions>
51+
<telerik:TreeListSortExpression FieldName="EmployeeName" SortOrder="Ascending" />
52+
</SortExpressions>
53+
</telerik:RadTreeList>
54+
````
55+
56+
Example 2: Programmatic Approach of setting the SortExpressions
57+
58+
````C#
59+
protected void Page_Load(object sender, EventArgs e)
60+
{
61+
if (!IsPostBack)
62+
{
63+
TreeListSortExpression sortExpr = new TreeListSortExpression();
64+
sortExpr.FieldName = "EmployeeName";
65+
sortExpr.SortOrder = TreeListSortOrder.Ascending;
66+
RadTreeList1.SortExpressions.AddSortExpression(sortExpr);
67+
68+
RadTreeList1.Rebind();
69+
}
70+
}
71+
````
72+
````VB.NET
73+
Protected Sub Page_Load(sender As Object, e As EventArgs)
74+
If Not IsPostBack Then
75+
Dim sortExpr As New TreeListSortExpression()
76+
sortExpr.FieldName = "EmployeeName"
77+
sortExpr.SortOrder = TreeListSortOrder.Ascending
78+
RadTreeList1.SortExpressions.AddSortExpression(sortExpr)
79+
80+
RadTreeList1.Rebind()
81+
End If
82+
End Sub
83+
````
84+
85+

0 commit comments

Comments
 (0)