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

Disappearing Context Menu

6 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seth
Top achievements
Rank 1
Seth asked on 17 Mar 2008, 03:08 PM
            function OnRowContextMenuCabinet(sender, eventArgs)  
            {  
                var rgCabinets = $find("<%= rgCabinets.MasterTableView.ClientID %>");  
                rgCabinets.selectItem(eventArgs.get_itemIndexHierarchical());               
            }  
 
                <telerik:radgrid id="rgCabinets" runat="server" datasourceid="sdsOFC_Cabinets" gridlines="None" 
                    skin="Vista" AllowPaging="True" PageSize="14">  
 
                    <MasterTableView DataSourceID="sdsOFC_Cabinets" AutoGenerateColumns="False"   
                            CommandItemDisplay="Top" ClientDataKeyNames="CabinetID">  
                        <Columns> 
                            <telerik:GridBoundColumn DataField="CabinetName" UniqueName="CabinetName" SortExpression="CabinetName" HeaderText="Cabinet Name"></telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn UniqueName="CabinetTemplateEditColumn">  
                                <ItemTemplate> 
                                    <asp:HyperLink ID="EditLink" runat="server" Text="Edit" /> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn UniqueName="CabinetTemplateDeleteColumn">  
                                <ItemTemplate> 
                                    <asp:HyperLink ID="DeleteLink" runat="server" Text="Delete" /> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                        </Columns> 
 
                        <CommandItemTemplate> 
                            <href="#" onclick="return ShowCabinetInsertForm();">Add A Cabinet</a> 
                        </CommandItemTemplate> 
                        <ExpandCollapseColumn Resizable="False" Visible="False">  
                            <HeaderStyle Width="20px" /> 
                        </ExpandCollapseColumn> 
                        <RowIndicatorColumn Visible="False">  
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                    </MasterTableView> 
                      
                    <ClientSettings> 
                        <ClientEvents OnRowContextMenu="OnRowContextMenuCabinet" /> 
                        <Selecting AllowRowSelect="true" /> 
                    </ClientSettings> 
                </telerik:radgrid> 
 
        <!-- Cabinets Context Menu --> 
        <telerik:RadContextMenu ID="rmCabinets" runat="server" Skin="Default2006" OnClientItemClicked="OnClickCabinet">  
            <Targets> 
                <telerik:ContextMenuControlTarget ControlID="rgCabinets" /> 
            </Targets> 
            <Items> 
                <telerik:RadMenuItem runat="server" Text="Edit" Value="Edit">  
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem runat="server" Text="Delete" Value="Delete">  
                </telerik:RadMenuItem> 
            </Items> 
        </telerik:RadContextMenu> 
 

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

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 18 Mar 2008, 01:34 PM
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
0
Seth
Top achievements
Rank 1
answered on 18 Mar 2008, 03:23 PM
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
0
Steve
Telerik team
answered on 21 Mar 2008, 12:44 PM
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
0
Seth
Top achievements
Rank 1
answered on 24 Mar 2008, 03:04 PM
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:

        <telerik:RadAjaxManager ID="ramTools" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="rgCabinets">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="rgCabinets" LoadingPanelID="ralpTools" /> 
                        <telerik:AjaxUpdatedControl ControlID="rgItemCategories" /> 
                        <telerik:AjaxUpdatedControl ControlID="rgItemTypes" /> 
                        <telerik:AjaxUpdatedControl ControlID="rgFolderTypes" /> 
                        <telerik:AjaxUpdatedControl ControlID="rmCabinets" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
...  
</telerik:RadAjaxManager.  
 

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
0
Sebastian
Telerik team
answered on 24 Mar 2008, 03:29 PM
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
0
Seth
Top achievements
Rank 1
answered on 24 Mar 2008, 03:45 PM
Solved.  Many thanks.
Tags
Grid
Asked by
Seth
Top achievements
Rank 1
Answers by
Steve
Telerik team
Seth
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or