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

How to disable postback or callback on RadTreeView click event

6 Answers 582 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 2
William asked on 25 Nov 2009, 12:32 PM
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.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Nov 2009, 12:49 PM
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.
0
Mickey
Top achievements
Rank 1
answered on 06 Dec 2010, 12:40 PM
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
0
Princy
Top achievements
Rank 2
answered on 06 Dec 2010, 01:31 PM
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.
0
Mickey
Top achievements
Rank 1
answered on 06 Dec 2010, 01:59 PM
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

0
Nikolay Tsenkov
Telerik team
answered on 09 Dec 2010, 01:56 PM
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.
0
Mickey
Top achievements
Rank 1
answered on 09 Dec 2010, 02:01 PM
Thanks,
I have manage to accomplish what I wanted
Tags
TreeView
Asked by
William
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Mickey
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or