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

RadTreeNode expandable but not selectable?

5 Answers 180 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Marja
Top achievements
Rank 1
Marja asked on 24 Jan 2014, 01:32 PM
Hi,

I use a RadTreeView to display a multi-level tree of news categories with their respective news items.

I want only the deepest node leveI (being the news item nodes) to be selectable, And so I would like the category nodes to be expandable, but not selectable. 

Setting the 'enabled' property of a category node to True also blocks its expandability, so that doesn't work for me.

Can you give me any pointers on how to make a RadTreeNode expandable but not selectable?
Thanks in advance.

Best regards, Marja

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jan 2014, 03:37 AM
Hi Marja,

Please try the following JavaScript to achieve your scenario.

JavaScript:
<script type="text/javascript">
    function pageLoad() {
        var tree = $find("<%=RadTreeView1.ClientID %>");
        tree.findNodeByText("Politics").expand();
    }
</script>

Thanks,
Shinu.
0
Marja
Top achievements
Rank 1
answered on 27 Jan 2014, 12:23 PM
Thank you for your reply, but that's not what I'm after. That's only expanding one branch statically, on page load.

I want the user to be able to expand/collapse tree branches as he pleases, while on the page, but only be able to really select the deepest nodes in the tree.
0
Shinu
Top achievements
Rank 2
answered on 28 Jan 2014, 02:57 AM
Hi Marja,

Please try the following JavaScript code snippet to select only the deepest nodes in RadTreeView.

JavaScript:
<script type="text/javascript">
    function OnClientNodeClicking1(sender, args) {
        var index = args.get_node().get_parent().get_nodes().get_count();
        if (args.get_node().get_parent().get_nodes()._array[index - 1].get_text() != args.get_node().get_text())
            args.set_cancel(true);
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
0
Anders
Top achievements
Rank 1
answered on 16 Feb 2016, 01:20 PM
I do not understand why you propose solutions involving scripting. Isnt that just workarounds?
0
Veselin Tsvetanov
Telerik team
answered on 18 Feb 2016, 03:33 PM
Hi Anders,

You have posted similar question in another Forum thread (Make node not selectable but expandable). I would suggest you to continue the discussion on this topic there.

Regards,
Veselin Tsvetanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Marja
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marja
Top achievements
Rank 1
Anders
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or