How to disable postback or callback on RadTreeView click event

7 posts, 0 answers
  1. William
    William avatar
    2 posts
    Member since:
    Jul 2009

    Posted 25 Nov 2009 Link to this post

    Hi, i want to disable postback or callback on RadTreeView when the user click a node, i also want with javascript function get the NavigateUrl and assign it to a iframe, all in client side without server side.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2009 Link to this post

    Hi William,

    Attach OnClientNodeClicking event to treeview so that you can cancel the postback/callback using the methos set_cancel(true) based on condition. Here is the example that I tried.

    JavaScript:
     
    <script type="text/javascript"
        function OnClientNodeClicking(sender, args) { 
            if (args.get_node().get_text() == "NavigateUrl") { 
                var url = args.get_node().get_navigateUrl(); // get the navigateurl 
                var if1 = document.getElementById("iframe1"); // get the iframe client object 
                if1.src = url; // Set the url 
                args.set_cancel(true);  // Cancell the event 
            } 
        } 
    </script> 

    Thanks,
    Princy.
  3. Mickey
    Mickey avatar
    39 posts
    Member since:
    Mar 2009

    Posted 06 Dec 2010 Link to this post

    I only need to cancel the post back
    I need the checkbox state to change as well, (original behavior)
    I tried to manually change it, but if fail
    please advise
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Dec 2010 Link to this post

    Hi Mickey,


    If you have attacted "OnNodeClick"  server event, then remove the handler and follow the code as shown below.

    Client code:
    function OnClientNodeClicked(sender, args) {
        var node = args.get_node();
        node.set_checked(!node.get_checked());
    }



    Thanks,
    Princy.
  5. Mickey
    Mickey avatar
    39 posts
    Member since:
    Mar 2009

    Posted 06 Dec 2010 Link to this post

    when I press the checkbox,
    the click event is NOT being fired, only when I press the text,
    I would like the control to function exactly as it used to, just without the post back

  6. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 09 Dec 2010 Link to this post

    Hello Mickey,

    Well, if there is a postback on NodeClick event, then you probably are handling this event on the server. Simply remove the handler if it's not needed.

    If you want to conditionally postback, this is another thing - you need to handle the ClientNodeClicking event and if you don't want to post-back, then args.set_cancel(true). If you want to still get the changes that this click does - add them in the handler of ClientNodeClick - for example:
    var node = args.get_node();
     
    args.set_cancel(true);
     
    // for selecting the node even when the click is canceled
    node.set_selected(true);

    If this is still not what you are looking for, please, explain in a bit more detail what seems to be the problem and if needed, please, illustrate it with some code, too


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  7. Mickey
    Mickey avatar
    39 posts
    Member since:
    Mar 2009

    Posted 09 Dec 2010 Link to this post

    Thanks,
    I have manage to accomplish what I wanted
Back to Top