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

[Solved] Problem with radcontextmenu into radpane?

2 Answers 67 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 08 Jun 2009, 07:47 AM
Hello,

Is there anyone who had experienced problems using a contextmenu into a radpane?

My problem is as follows:
I have an input button into a radpane and an a javascript function that shows the context menu when the button is clicked. But when the menu is displayed it collapses inmediately. I have copied the code and pasted it outside the radpane and then it works fine.

2 Answers, 1 is accepted

Sort by
0
Luis
Top achievements
Rank 1
answered on 08 Jun 2009, 08:44 AM
Trying other solutions, I have found out that the problem hasn't to do with radpane, but with formdecorator.

It happens when the button is decorated. Here is my code:

<script type="text/javascript">
function showMenu(e) {
          var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
                 
          contextMenu.showAt(e.screenX, e.screenY);          
        }
</script>

<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="Buttons"
                              DecoratedControls="All" />
<div id="Buttons" >
      <input id="Button1" type="button" onclick="showMenu(event)" value="Sections" />
                    <telerik:RadContextMenu ID="RadContextMenu1" runat="server" CollapseDelay="50000">
                      <Items> 
...
                      </Items>
                    </telerik:RadContextMenu>
    </div>


Any help?
0
Accepted
Svetlina Anati
Telerik team
answered on 11 Jun 2009, 10:33 AM
Hi Luis,

In general, you should cancel the event in order to prevent it to bubble to the document and this is done by calling $telerik.cancelRawEvent(event) as highlighted below:

http://www.telerik.com/help/aspnet-ajax/menu_clientsideradmenuradcontextmenu.html

In the case when the button is decorated by the RadFormDecorator, you should do this with a little timeout as shown below:

function showMenu(e) {  
      
      
          var contextMenu = $find("<%= RadContextMenu1.ClientID %>");   
            
          var x = e.screenX;  
          var y = e.screenY;  
          setTimeout(function()  
          {            
            contextMenu.showAt(x, y);   
          }, 100);  
                      
          $telerik.cancelRawEvent(e);        
            
        }  
        </script>  
 



All the best,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Menu
Asked by
Luis
Top achievements
Rank 1
Answers by
Luis
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or