2015-11-25 189 views
0

我想讓我的RadContextMenu在使用左鍵單擊時保持打開狀態。當我使用鼠標右鍵單擊時,它會發揮作用,因爲這是默認設置,但我也想在右鍵單擊時打開上下文菜單,打開後立即關閉它。RadContextMenu關閉按鈕單擊

佈局

<telerik:RadButton ID="btnGenerate" runat="server" 
     Text="Generate..." ToolTip="Click to generate the tracking/tags/preview for the current creative" 
     OnClientClicked="generateMenuItemOnLeftClick"> 
    </telerik:RadButton> 
    <telerik:RadContextMenu ID="cmGenerate" runat="server" Flow="Horizontal" 
     OnItemClick="cmGenerate_ItemClick" OnClientItemClicking="generateMenuItemClicking"> 
     <Items> 
      <telerik:RadMenuItem runat="server" Text="Generate Tracking" Value="generateTracking" /> 
      <telerik:RadMenuItem runat="server" Text="Generate Preview" Value="generatePreview" /> 
      <telerik:RadMenuItem runat="server" Text="Generate Tags" Value="generateTags" /> 
     </Items> 
     <Targets> 
      <telerik:ContextMenuControlTarget ControlID="btnGenerate" /> 
     </Targets> 
    </telerik:RadContextMenu> 

JS

 function generateMenuItemOnLeftClick(sender, eventArgs) { 
      var currentLocation = $telerik.getLocation(sender.get_element()); 
      var contextMenu = $find("<%=cmGenerate.ClientID%>"); 
      contextMenu.showAt(currentLocation.x, currentLocation.y + 22); 
     } 

回答

1

這是誰具有相同的問題的其他人。我發現,你必須調用

$telerik.cancelRawEvent(event); 

一個showAt(..)方法之後。這取消了即時關閉的默認行爲。