Limiting the levels in a TreeView

4 posts, 0 answers
  1. Ian
    Ian avatar
    2 posts
    Member since:
    Feb 2012

    Posted 16 Apr 2012 Link to this post

    What is the method for limiting the number of levels in a TreeView?

    Can't seem to find anything about this.
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 17 Apr 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Ian
    Ian avatar
    2 posts
    Member since:
    Feb 2012

    Posted 17 Apr 2012 Link to this post

    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.

  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 Apr 2012 Link to this post

    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 >>

Back to Top