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

Limiting the levels in a TreeView

3 Answers 107 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ian
Top achievements
Rank 1
Ian asked on 16 Apr 2012, 09:24 AM
What is the method for limiting the number of levels in a TreeView?

Can't seem to find anything about this.

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 17 Apr 2012, 01:12 PM
Hello Ian,

 Could you please elaborate more on your desired scenario? How do you  populate your RadTreeView? Do you use HierarchicalDataTemplates? Usually the RadTreeView is the visual presentation of your hierarchical data stored in DB / business objects / ViewModels. So it is always easier to control the ViewModels and let the RadTreeView build its containers (RadTreeViewItems) automatically by configuring properly its hierarchical templates. Isn't it suitable for you to limit your ViewModels / business objects?

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ian
Top achievements
Rank 1
answered on 17 Apr 2012, 01:18 PM
Hi Petar,

I'm dragging the entries for the treeView in from a RadGrid and I want to limit it so that users cannot create any levels at all.

I just want to have it so that there is only ONE tree level.

How do I set this up?

Thanks.

0
Petar Mladenov
Telerik team
answered on 20 Apr 2012, 09:56 AM
Hello Ian,

 In databinding scenarios, you usually provide telerik 's HierarchicalDataTemplate  to the ItemTemplate of the RadTreeView. This allows you to use the ItemTemplate and the ItemsSource properties of the HierarchicalDataTemplate and create hierarchy. When not set explicitly, these properties are automatically inherited from the RadTreeView or from the parent HierarchicalCollection. The way to use only one tree level when providing a hierarchy of classes/ viewmodels is to give the ItemTemplate of the RadTreeView a simple
DataTemplate.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
Ian
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Ian
Top achievements
Rank 1
Share this question
or