RadTreeView, how to disable sorting

2 posts, 0 answers
  1. E
    E avatar
    1 posts
    Member since:
    Apr 2012

    Posted 18 Apr 2012 Link to this post

    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.

  2. Plamen
    Plamen avatar
    2723 posts

    Posted 21 Apr 2012 Link to this post


    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",
           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;

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top