RadContextMenu ExpandDelay not working as expected

3 posts, 1 answers
  1. Brian Gabel
    Brian Gabel avatar
    6 posts
    Member since:
    Sep 2008

    Posted 24 Jul 2009 Link to this post

        <script type="text/javascript"
            function showCreateMenu(e) { 
                var contextMenu = $find("<%= CreateMenuOptions.ClientID %>"); 
     
                if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) { 
                    contextMenu.show(e); 
                } 
     
                $telerik.cancelRawEvent(e); 
            } 
             
            function OnClientShowingHandler(sender, args) { 
                var element = sender.get_contextMenuElement(); 
                var handler = function(e) { 
                    var relatedTarget = e.rawEvent.relatedTarget || e.rawEvent.toElement; 
                    if (!$telerik.isDescendantOrSelf(element, relatedTarget)) { 
                        sender.hide(); 
                        $removeHandler(element, "mouseout", handler); 
                        return
                    } 
                }; 
     
                $addHandler(element, "mouseout", handler); 
            } 
        </script> 

        <telerik:RadContextMenu ID="CreateMenuOptions" runat="server" OnClientShowing="OnClientShowingHandler" ExpandDelay="500"
            <Items> 
                <telerik:RadMenuItem Text="Create Sales Order" Value="mnuCreateSO" /> 
                <telerik:RadMenuItem Text="Create Quote" Value="mnuCreateQuote" /> 
            </Items> 
            <Targets> 
                <telerik:ContextMenuControlTarget ControlID="CreateMenuOptions" /> 
            </Targets> 
        </telerik:RadContextMenu>    
         
        <asp:ImageButton ID="btnCreate" runat="server" CommandName="Create" onmouseover="showCreateMenu(event);" ImageUrl="~/images/toolbar_icon.png"></asp:ImageButton> 

    I have an ImageButton mouseover event which calls a JS function to show a RadContextMenu. This function works properly. However, the ExpandDelay setting of the RadContextMenu is not being used. When I mouseover the ImageButton the menu is displayed immediately. What can I do about this? I am using the 2009.1.402.35 controls.

  2. Answer
    Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 27 Jul 2009 Link to this post

    Hello Brian,

    The ExpandDelay property is intended to work only when the RadContextMenu is invoked by normal means, like right click. If you want to have delay when showing the RadContextMenu with javascript, please use setTimeout().

    Regards,
    Kamen Bundev
    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.
  3. Brian Gabel
    Brian Gabel avatar
    6 posts
    Member since:
    Sep 2008

    Posted 27 Jul 2009 Link to this post

    Thanks, Kamen, that will work.

        <script type="text/javascript"
            var timeoutId; 
     
            function showCreateMenu(e) { 
                var contextMenu = $find("<%= CreateMenuOptions.ClientID %>"); 
     
                if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) { 
                    contextMenu.show(e); 
                } 
     
                $telerik.cancelRawEvent(e); 
            } 
        </script> 
     

    <asp:Image ID="btnCreate" runat="server" CommandName="Create" onmouseover="timeoutId = setTimeout(function() {showCreateMenu(event)}, 500);" onmouseout="clearTimeout(timeoutId);" CssClass="aiIcon1" Enabled='<%# RadGrid1.EditIndexes.Count == 0 %>' ImageUrl="~/images/toolbar_icon.png"></asp:Image> 



Back to Top