How to disable ContextMenu in NestedViewTemplate

3 posts, 0 answers
  1. VnDevil
    VnDevil avatar
    58 posts
    Member since:
    Oct 2012

    Posted 17 Feb 2010 Link to this post

    Hi, I have a NestedViewTemplate with a RadGrid in a RadGrid. Now I can't disable ContextMenu in the NestedViewTemplate. Please help

            <cc3:RadGrid ID="RadGrid1" runat="server" OnItemCommand="RadGrid1_ItemCommand" OnInit="RadGrid1_OnInit" 
                OnItemCreated="RadGrid1_ItemCreated" OnPreRender="RadGrid1_OnPreRender" OnItemDataBound="RadGrid1_ItemDataBound"
                <MasterTableView DataKeyNames="Group_ID"
                    <NestedViewTemplate> 
                        <asp:Panel runat="server" ID="InnerContainer" Visible="false"
                            <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("Group_ID") %>' 
                                Visible="false" runat="server" /> 
                            <asp:Label ID="Label2" Font-Bold="true" Font-Italic="true" Text='<%# Eval("Portal_ID") %>' 
                                Visible="false" runat="server" /> 
                            <asp:Label ID="Label3" Font-Bold="true" Font-Italic="true" Text='<%# Eval("Language") %>' 
                                Visible="false" runat="server" /> 
                            <cc3:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource2" OnInit="RadGrid2_OnInit" 
                                OnItemCommand="RadGrid2_ItemCommand"
                                <MasterTableView> 
                                    <Columns> 
                                        <telerik:GridNumericColumn DataField="Nick_Index" UniqueName="Nick_Index" HeaderText=""
                                        </telerik:GridNumericColumn> 
                                        <telerik:GridBoundColumn DataField="Nick_Name" UniqueName="Nick_Name" HeaderText=""
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="Nick_Title" UniqueName="Nick_Title" HeaderText=""
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridCheckBoxColumn DataField="Nick_Status" UniqueName="Nick_Status" HeaderText=""
                                        </telerik:GridCheckBoxColumn> 
                                        <telerik:GridTemplateColumn UniqueName="Functions" AllowFiltering="false" Groupable="false" 
                                            HeaderStyle-Font-Bold="True" HeaderText=""
                                            <ItemTemplate> 
                                                <cc5:LinkButtonEdit ID="btnEditNick" runat="server" CommandArgument='<%# Eval("Nick_ID") %>' /> 
                                                | 
                                                <cc5:LinkButtonDelete ID="btnDeleteNick" runat="server" CommandArgument='<%# Eval("Nick_ID") %>' /> 
                                            </ItemTemplate> 
                                        </telerik:GridTemplateColumn> 
                                    </Columns> 
                                </MasterTableView> 
                                <ClientSettings> 
                                    <Selecting AllowRowSelect="false"/> 
                                </ClientSettings> 
                            </cc3:RadGrid> 
                            <asp:SqlDataSource ID="SqlDataSource2" ConnectionString='<%$ ConnectionStrings:Portal_ConnectionString %>' 
                                ProviderName="System.Data.SqlClient" SelectCommand="EXEC [OnlineSupport_Nicks_GetNicksByGroup] @Portal_ID, @Group_ID, @Language" 
                                runat="server"
                                <SelectParameters> 
                                    <asp:ControlParameter ControlID="Label1" PropertyName="Text" Type="int32" Name="Group_ID" /> 
                                    <asp:ControlParameter ControlID="Label2" PropertyName="Text" Type="int32" Name="Portal_ID" /> 
                                    <asp:ControlParameter ControlID="Label3" PropertyName="Text" Type="String" Name="Language" /> 
                                </SelectParameters> 
                            </asp:SqlDataSource> 
                        </asp:Panel> 
                    </NestedViewTemplate> 
                    <Columns> 
                        <telerik:GridNumericColumn DataField="Group_Index" UniqueName="Group_Index" HeaderText=""
                        </telerik:GridNumericColumn> 
                        <telerik:GridBoundColumn DataField="Group_Name" UniqueName="Group_Name" HeaderText=""
                        </telerik:GridBoundColumn> 
                        <telerik:GridCheckBoxColumn DataField="Group_Enable" UniqueName="Group_Enable" HeaderText=""
                        </telerik:GridCheckBoxColumn> 
                        <telerik:GridTemplateColumn UniqueName="Functions" AllowFiltering="false" Groupable="false" 
                            HeaderStyle-Font-Bold="True" HeaderText=""
                            <ItemTemplate> 
                                <cc5:LinkButtonEdit ID="btnEdit" runat="server" CommandArgument='<%# Eval("Group_ID") %>' /> 
                                | 
                                <cc5:LinkButtonDelete ID="btnDelete" runat="server" CommandArgument='<%# Eval("Group_ID") %>' /> 
                                | 
                                <cc5:LinkButton ID="btnAddNick" runat="server" CommandArgument='<%# Eval("Group_ID") %>' 
                                    CommandName="AddNick"></cc5:LinkButton> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                    </Columns> 
                </MasterTableView> 
                <ClientSettings> 
                    <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents> 
                    <Selecting AllowRowSelect="true" /> 
                </ClientSettings> 
            </cc3:RadGrid> 
            <cc3:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicking="onClientContextMenuItemClicking" OnItemClick="RadContextMenu1_ItemClick" 
                OnInit="RadContextMenu1_OnInit"
                <Items> 
                    <telerik:RadMenuItem Value="AddNick" Text="" /> 
                    <telerik:RadMenuItem Value="Edit" Text="" /> 
                    <telerik:RadMenuItem Value="Delete" Text="" Font-Bold="true"/> 
                </Items> 
            </cc3:RadContextMenu> 

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Feb 2010 Link to this post

    Hello,

    Try modifying the RowContextMenu handler and see whether it helps.

    JavaScript:
     
        var id = ""
        function OnGridCreated(sender, args) { 
            id = sender.get_id(); 
        } 
     
        function RowContextMenu(sender, eventArgs) { 
            var menu = $find("<%=RadMenu1.ClientID %>"); 
            var evt = eventArgs.get_domEvent(); 
            var grid = $find("<%=RadGrid1.ClientID %>"); 
            if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") { 
                return
            } 
     
            var secondGridID = evt.target.parentElement.id; 
            if (secondGridID.indexOf(id) == 0) { 
                return
            } 
     
     
            var index = eventArgs.get_itemIndexHierarchical();        sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 
            menu.show(evt); 
            evt.cancelBubble = true
            evt.returnValue = false
     
            if (evt.stopPropagation) { 
                evt.stopPropagation(); 
                evt.preventDefault(); 
            } 
        } 
    [Attach OnGridCreated event to RadGrid2]

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. VnDevil
    VnDevil avatar
    58 posts
    Member since:
    Oct 2012

    Posted 17 Feb 2010 Link to this post

    Thanks for help, it worked :D
Back to Top