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

Sorting in treeView

6 Answers 266 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Prash
Top achievements
Rank 1
Prash asked on 12 Mar 2009, 11:22 AM
hello,

I have a requirement that the treeView should get sorted according to some parameter.
Is this possible to achieve ?
A code sample would be helpful.

Thanks and regards 

6 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 13 Mar 2009, 12:30 PM

Hello Prash,

Here is how you can sort your items:

treeView.Items.Add(new RadTreeViewItem() { Header = "C" });
treeView.Items.Add(new RadTreeViewItem() { Header = "F" });
treeView.Items.Add(new RadTreeViewItem() { Header = "A" });
treeView.Items.Add(new RadTreeViewItem() { Header = "D" });
treeView.Items.Add(new RadTreeViewItem() { Header = "B" });
treeView.Items.Add(new RadTreeViewItem() { Header = "E" });

treeView.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Header", System.ComponentModel.ListSortDirection.Ascending));

Let me know if you have further questions.

Regards,

Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Prash
Top achievements
Rank 1
answered on 13 Mar 2009, 02:17 PM
Hello Tihomir,

Thanks for the reply, but I have already tried it, I have the treeview which has more than five levels. Sorting is working fine for the 2nd level onwards but not for the first. Can you please reply on the same.

Thanks and regards
0
Prash
Top achievements
Rank 1
answered on 16 Mar 2009, 11:38 AM
Hello,

I have observed the treeView closely, and have come to know that the treeview sorting is behaving erroneously and the multilevel treeview is not getting sorted properly.

There is a root node, site, and the first level children are the network groups, and the hierarchy goes on till 5 levels. but the sorting is not there in the 2nd level and the 4th level.

can you please look into this.
Thanks and regards
0
Tihomir Petkov
Telerik team
answered on 16 Mar 2009, 11:51 AM
Hello Prash,

Maybe I am missing something, but the code I sent you in my first reply sorts the *first* level of items and you are saying you tried it and it works from the second level onwards. I tested the sample with a hierarchy of 6 levels and sorting seems to work fine. Can you please send me a sample project which demonstrates your scenario in which sorting does not work?

All the best,
Tihomir Petkov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Prash
Top achievements
Rank 1
answered on 18 Mar 2009, 04:52 AM
Hello,
I am preparing the sample for the same, the problem here is the Demand On Load, i guess, because the normal samples are working fine for the sorting, but we have implemented the treeview with Demand on Load, this may be the problem i guess. Can you please look into the On demand load on treeview for sorting. That will be helpful.
0
Prash
Top achievements
Rank 1
answered on 27 Mar 2009, 11:37 AM
Hello
i tried puting sorting description in the itemsPrepared event and that helped


Tags
TreeView
Asked by
Prash
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Prash
Top achievements
Rank 1
Share this question
or