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

how to Cancel Event OnClientNodeClicked

3 Answers 469 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Wilson
Top achievements
Rank 1
Wilson asked on 27 Jan 2012, 10:55 PM
Hi

I have to cancel the event if the condition is False, for example: I have a treeview with images, before opening the image is valid if the image is already displayed, if it is  already displayed have to cancel the event, not allowing it to spread

how I do this

thanks

<telerik:RadTreeView ID="DocTreeView" runat="server" CssClass="cssTreeView" Height="100%"
Width="285"  OnClientNodeClicked ="onclickTreeview" onNodeClick="DocTreeView_NodeClick">
 </telerik:RadTreeView>

My Jquery Code
function onclickTreeview(sender, args) {
     
       code........
        
        if (!AllowImageOpen) {
            alert('This image is now displayed');
            // cancel the event here
        }
    }
}

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jan 2012, 06:42 AM
Hello Wilson,

You can attatching the onClientNodeClickeing Event  and cancel the event.  Here is the help documentation.
OnClientNodeClicking.

Thanks,
Shinu.
0
Pure
Top achievements
Rank 1
answered on 12 Jul 2012, 12:50 PM
Could you please help?
I have tried AJAX ASP.NET of Telerik version 2012 Q2.
For the treeview control, "OnClientNodeClicking" is not like as it was described in the manual.
This client event returning the node newly click by the user.
You can try with the code from their example.

<script type="text/javascript" language="javascript">

    function ClientNodeClicking(sender, eventArgs) {
        var node = eventArgs.get_node();
        if (node.get_text() == "Search") {
            eventArgs.set_cancel(true);
        }
    }
</script>

In short, right now, the client event "OnClientNodeClicking" and "OnClientNodeClicked" will return the same node when you using 
"var node = eventArgs.get_node();" inside both events.
Also in the TelerikDemo page "http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/clientevents/defaultcs.aspx",
there is no client event "OnClientNodeClicked" event used in the demo.
Why is that???


0
Ivana
Telerik team
answered on 16 Jul 2012, 04:06 PM
Hi palakorn,

The NodeClicking client event of RadTreeView is fired just before a node is clicked, and the NodeClicked client event is fired right after that -- when a node is clicked.

The  client NodeClicking event can be canceled using the eventArgs argument and its method set_cancel(boolean). For more information you could take a look at the help articles linked above.

I hope this will help.

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Wilson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pure
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or