Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > Disable Node click for Particular Node Level

Answered Disable Node click for Particular Node Level

Feed from this thread
  • Posted on Apr 27, 2012 (permalink)

    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

    Reply

  • Posted on Apr 27, 2012 (permalink)

    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.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • Posted on Apr 27, 2012 (permalink)

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


    Thanks
    Krishna

    Reply

  • Answer Shinu MVP avatar

    Posted on Apr 27, 2012 (permalink)

    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.

    Reply

  • Answer Avinash Tauro avatar

    Posted on May 18, 2012 (permalink)

    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. 

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > Disable Node click for Particular Node Level
Related resources for "Disable Node click for Particular Node Level"

ASP.NET TreeView Features  |   Documentation   |  Demos  |  Step-by-step Tutorial  ]