Disable Node click for Particular Node Level

5 posts, 2 answers
  1. Phaneendra
    Phaneendra avatar
    27 posts
    Member since:
    Jul 2011

    Posted 27 Apr 2012 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phaneendra
    Phaneendra avatar
    27 posts
    Member since:
    Jul 2011

    Posted 27 Apr 2012 Link to this post

    Hi shinu
    Code snipplet is not working, getting error, object doesn't support


    Thanks
    Krishna
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2012 Link to this post

    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.
  6. Answer
    Avinash Tauro
    Avinash Tauro avatar
    7 posts
    Member since:
    Oct 2009

    Posted 18 May 2012 Link to this post

    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. 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017