Is there a event handler for right click event on the tree node?

4 posts, 1 answers
  1. Onkar
    Onkar avatar
    3 posts
    Member since:
    Jul 2012

    Posted 12 Jul 2012 Link to this post

    I have a RadTreeView on the click the nodes get selected and then at the right click a context menu is shown. This is working fine but the problem is to a context menu for a node I have to first select it and then right click on it. Is there a way by which directly on the right click the node will be selected and the context menu will appear for it.
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 12 Jul 2012 Link to this post

    Hi,

    You can handle OnClientContextMenuShowing:
    <script type="text/javascript">
           function OnClientContextMenuShowing(sender, args) {
               alert(1);
           }
       </script>
       <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuShowing="OnClientContextMenuShowing">
           <Nodes>
               <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">
                   <Nodes>
                       <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">
                       </telerik:RadTreeNode>
                       <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">
                       </telerik:RadTreeNode>
                   </Nodes>
               </telerik:RadTreeNode>
               <telerik:RadTreeNode runat="server" Text="Root RadTreeNode2">
               </telerik:RadTreeNode>
           </Nodes>
       </telerik:RadTreeView>


    Regards,
    Peter
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Onkar
    Onkar avatar
    3 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    Hi Peter,

    Thanks for your reply. I tried using the  OnClientContextMenuShowing but the problem is I need to make a call to a server side function. I have a function which handles the OnNodeClick event I need to call the same function when the right click is done. I tried using the client side method and from there trying to invoke the server side method but that was not possible. Could you suggest me a way how that can be accomplished.
  5. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 30 Jul 2012 Link to this post

    Hi Onkar,

    Please, try the following:
    <script type="text/javascript">
     
           function OnClientContextMenuShowing(sender, args) {
               args.get_node().select();
               $telerik.cancelRawEvent(args.get_domEvent());
           }
     
       </script>
       <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuShowing="OnClientContextMenuShowing"
           OnNodeClick="RadTreeView1_NodeClick">
           <Nodes>
               <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">
                   <Nodes>
                       <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">
                       </telerik:RadTreeNode>
                       <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">
                       </telerik:RadTreeNode>
                   </Nodes>
               </telerik:RadTreeNode>
               <telerik:RadTreeNode runat="server" Text="Root RadTreeNode2">
               </telerik:RadTreeNode>
           </Nodes>
       </telerik:RadTreeView>

    protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
       {
           Response.Write(e.Node.Text);
       }


    Kind regards,
    Peter
    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