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

Disable Node click for Particular Node Level

4 Answers 283 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Phaneendra
Top achievements
Rank 1
Phaneendra asked on 27 Apr 2012, 06:37 AM
Hi,

I have a RadTreeView, binded from database of 5 Levels.
Handling the Node click from client side, now I'm facing an issue, if the Node level is 2 I have to block the node click no post back should happend when user clicks on that node.

Regards
Krishna

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Apr 2012, 07:33 AM
Hi Krishna,

Try the following code to block the node click from client side.

JS:
<script type="text/javascript">
    function OnClientNodeClicking(sender, args)
    {
        if (args.get_node().get_level() == 2)
            args.set_cancel(true);
    }
</script>

Thanks,
Shinu.
0
Phaneendra
Top achievements
Rank 1
answered on 27 Apr 2012, 09:45 AM
Hi shinu
Code snipplet is not working, getting error, object doesn't support


Thanks
Krishna
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Apr 2012, 10:56 AM
Hi Krishna,

Here is the code that worked for me as expected.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" DataTextField="name" DataFieldID="id" DataSourceID="SqlDataSource1" DataFieldParentID="parent" OnClientNodeClicking="OnClientNodeClicking">
</telerik:RadTreeView>

JS:
<script type="text/javascript">
    function OnClientNodeClicking(sender, args)
    {
        if (args.get_node().get_level() == 2)
            args.set_cancel(true);
    }
</script>

Please provide your full code if it doesn't helps.

Thanks,
Shinu.
Theo
Top achievements
Rank 2
commented on 19 Jan 2022, 02:47 PM

Works for me! 

Thanks :)
0
Accepted
Avinash Tauro
Top achievements
Rank 1
answered on 18 May 2012, 03:27 PM
This solution works partially. So set_cancel(true) in node clicking correctly prevents postback but also prevents the node from being selected.
Adding args.get_node().set_selected(true);  in the function selects the node. 
Tags
TreeView
Asked by
Phaneendra
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Phaneendra
Top achievements
Rank 1
Avinash Tauro
Top achievements
Rank 1
Share this question
or