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

Select only child (leaf) nodes

4 Answers 227 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 23 Oct 2008, 11:03 PM
How would I implement a treeview where a user could only select nodes at the tip of the tree (i.e. "leaves")?  I've tried "rtn.Enabled = false;", "rtn.PostBack = false;" (since I embedded the RadTreeView in a RadComboBox control), and "rtn.Checkable = false;" for the RadTreeNode, all which provide part of the functionality I need, but either provide too much ("Enabled = false" makes it so I can't select the node, but then I can't expand the node, either), or not enough ("Checkable = false" doesn't apply when I haven't added checkboxes).  Did I miss a setting for this?

4 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 1
answered on 23 Oct 2008, 11:19 PM
I also searched in case the RadTreeView control had a setting, but couldn't find one.
0
Veselin Vasilev
Telerik team
answered on 24 Oct 2008, 02:52 PM
Hello Jay,

What you need to do is subscribe to the OnClientNodeClicking event of the treeview and cancel it if the clicked node has children (if (node.get_nodes().get_count() > 0)

I hope this helps.

Kind regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jay
Top achievements
Rank 1
answered on 24 Oct 2008, 08:43 PM
Thanks, that does help.

But to work alongside that, how do I prevent the RadComboBox from closing when I select that invalid entry?  Do I need to overwrite the RadComboBox's OnClientDropDownClosing handler or do I have another option?
0
Veselin Vasilev
Telerik team
answered on 27 Oct 2008, 08:31 AM
Hello Jay,

You need to wrap the treeview in a div and cancel bubbling when clicking in the div. You can check our online example for the implementation.

Best wishes,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Jay
Top achievements
Rank 1
Answers by
Jay
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or