how to Cancel Event OnClientNodeClicked

4 posts, 0 answers
  1. Wilson
    Wilson avatar
    3 posts
    Member since:
    May 2011

    Posted 27 Jan 2012 Link to this post

    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
            }
        }
    }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Jan 2012 Link to this post

    Hello Wilson,

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

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pure
    Pure avatar
    1 posts
    Member since:
    Mar 2007

    Posted 12 Jul 2012 Link to this post

    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???
    
    
    
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 16 Jul 2012 Link to this post

    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.
Back to Top