This is a migrated thread and some comments may be shown as answers.

RadTreeView, how to disable sorting

1 Answer 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
E
Top achievements
Rank 1
E asked on 18 Apr 2012, 07:51 AM
The treeview sorts the items regardless of the way they are added to it (as a collection or individually).
I'd like to disable the auto sorting of the items in the tree but so far can't see the .sort() method as outlined in some other posts.

The version used is v2012.1.301.35 Trial.

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 Apr 2012, 09:35 AM
Hi,

 
Currently there is not sorting method implemented in RadTreeView and the nodes are added in the order they have been added as it is shown in the Programmatic DataBinding demo.

If you want to implement some custom sorting I will recommend you to do it additionally as in the code:

private static void BindToDataSet(RadTreeView treeView)
   {
       SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Employees",
               ConfigurationManager.ConnectionStrings["TelerikVSXConnectionString"].ConnectionString);
 
       DataSet links = new DataSet();
 
       adapter.Fill(links, "Employees");
       DataView view = links.Tables["Employees"].DefaultView;
       // To sort in ascending order:
 
       view.Sort = "LastName" + " ASC";
       // To sort in descending order:
      // view.RowFilter = "LastName = 'Fuller'";
      // view.Sort = "LastName" + " DESC";
 
       treeView.DataTextField = "LastName";
       treeView.DataFieldID = "EmployeeID";
       treeView.DataFieldParentID = "ReportsTo";
 
       treeView.DataSource = view;
       treeView.DataBind();
   }

Hope this will be helpful.

Kind regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
E
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or