Disappearing Context Menu

7 posts, 0 answers
  1. Seth
    Seth avatar
    90 posts
    Member since:
    Jun 2007

    Posted 17 Mar 2008 Link to this post

    1             function OnRowContextMenuCabinet(sender, eventArgs)  
    2             {  
    3                 var rgCabinets = $find("<%= rgCabinets.MasterTableView.ClientID %>");  
    4                 rgCabinets.selectItem(eventArgs.get_itemIndexHierarchical());               
    5             }  
    6  
    7                 <telerik:radgrid id="rgCabinets" runat="server" datasourceid="sdsOFC_Cabinets" gridlines="None" 
    8                     skin="Vista" AllowPaging="True" PageSize="14">  
    9  
    10                     <MasterTableView DataSourceID="sdsOFC_Cabinets" AutoGenerateColumns="False"   
    11                             CommandItemDisplay="Top" ClientDataKeyNames="CabinetID">  
    12                         <Columns> 
    13                             <telerik:GridBoundColumn DataField="CabinetName" UniqueName="CabinetName" SortExpression="CabinetName" HeaderText="Cabinet Name"></telerik:GridBoundColumn> 
    14                             <telerik:GridTemplateColumn UniqueName="CabinetTemplateEditColumn">  
    15                                 <ItemTemplate> 
    16                                     <asp:HyperLink ID="EditLink" runat="server" Text="Edit" /> 
    17                                 </ItemTemplate> 
    18                             </telerik:GridTemplateColumn> 
    19                             <telerik:GridTemplateColumn UniqueName="CabinetTemplateDeleteColumn">  
    20                                 <ItemTemplate> 
    21                                     <asp:HyperLink ID="DeleteLink" runat="server" Text="Delete" /> 
    22                                 </ItemTemplate> 
    23                             </telerik:GridTemplateColumn> 
    24                         </Columns> 
    25  
    26                         <CommandItemTemplate> 
    27                             <href="#" onclick="return ShowCabinetInsertForm();">Add A Cabinet</a> 
    28                         </CommandItemTemplate> 
    29                         <ExpandCollapseColumn Resizable="False" Visible="False">  
    30                             <HeaderStyle Width="20px" /> 
    31                         </ExpandCollapseColumn> 
    32                         <RowIndicatorColumn Visible="False">  
    33                             <HeaderStyle Width="20px" /> 
    34                         </RowIndicatorColumn> 
    35                     </MasterTableView> 
    36                       
    37                     <ClientSettings> 
    38                         <ClientEvents OnRowContextMenu="OnRowContextMenuCabinet" /> 
    39                         <Selecting AllowRowSelect="true" /> 
    40                     </ClientSettings> 
    41                 </telerik:radgrid> 
    42  
    43         <!-- Cabinets Context Menu --> 
    44         <telerik:RadContextMenu ID="rmCabinets" runat="server" Skin="Default2006" OnClientItemClicked="OnClickCabinet">  
    45             <Targets> 
    46                 <telerik:ContextMenuControlTarget ControlID="rgCabinets" /> 
    47             </Targets> 
    48             <Items> 
    49                 <telerik:RadMenuItem runat="server" Text="Edit" Value="Edit">  
    50                 </telerik:RadMenuItem> 
    51                 <telerik:RadMenuItem runat="server" Text="Delete" Value="Delete">  
    52                 </telerik:RadMenuItem> 
    53             </Items> 
    54         </telerik:RadContextMenu> 
    55  

    I have a number of RadGrids which all have a context menu assigned to them.  When the grid is updated via an AJAX request, whether it is call I make or simply navigating to the next set of records, the context menu is lost/does not execute when called.

    Any ideas?

    Seth
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 18 Mar 2008 Link to this post

    Hi Seth,

    And what are your AjaxSettings? Do you update the context menu as well as the grid when a request is initiated?

    Kind regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Seth
    Seth avatar
    90 posts
    Member since:
    Jun 2007

    Posted 18 Mar 2008 Link to this post

    Well, this specific control updates itself and 3 other grids.  I do not update any of the context menus.  All that is handled in the ajax request is refreshing the grid after an insertion, update, or deletion; as well as navigation.  Regardless of the scenario, I lose the context menu.

    The only difference I see between my project and the examples given online for context menus is that I am using the <telerik:ContextMenuControlTarget> property of the RadContextMenu.  Whereas online, the context menu popup is actually handled by the OnRowContextMenu ClientEvents event.

    Seth
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 21 Mar 2008 Link to this post

    Hello Seth,

    Me asking if you update the menu or not was no coincidence. You need to update it as otherwise it would stay hooked up to the old radgrid client object, which of course is already disposed. I am attaching a simple test, using your code.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Seth
    Seth avatar
    90 posts
    Member since:
    Jun 2007

    Posted 24 Mar 2008 Link to this post

    Thank you for the info.  I made the change like you suggested, and now I get this error:

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    Here is my change:

    1         <telerik:RadAjaxManager ID="ramTools" runat="server">  
    2             <AjaxSettings> 
    3                 <telerik:AjaxSetting AjaxControlID="rgCabinets">  
    4                     <UpdatedControls> 
    5                         <telerik:AjaxUpdatedControl ControlID="rgCabinets" LoadingPanelID="ralpTools" /> 
    6                         <telerik:AjaxUpdatedControl ControlID="rgItemCategories" /> 
    7                         <telerik:AjaxUpdatedControl ControlID="rgItemTypes" /> 
    8                         <telerik:AjaxUpdatedControl ControlID="rgFolderTypes" /> 
    9                         <telerik:AjaxUpdatedControl ControlID="rmCabinets" /> 
    10                     </UpdatedControls> 
    11                 </telerik:AjaxSetting> 
    12 ...  
    13 </telerik:RadAjaxManager.  
    14  

    What am I doing wrong?  I see that your initiator contorl is the manager itself whereas mine is the grid.  I don't know if that makes a difference...

    Seth
  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 24 Mar 2008 Link to this post

    Hello Seth,

    You need to wrap your javascript code inside RadCodeBlock to avoid the exception when using server tags. More info on the subject can be found here:

    http://www.telerik.com/help/radcontrols/prometheus/?ajxRadScriptBlockRadCodeBlock.html

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Seth
    Seth avatar
    90 posts
    Member since:
    Jun 2007

    Posted 24 Mar 2008 Link to this post

    Solved.  Many thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017