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

Hide RadContextMenu in detailtable

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aspliid
Top achievements
Rank 1
aspliid asked on 23 Oct 2014, 09:08 PM
I have a nested radgrid, with a single detailtable. I have set it up with a RadContextMenu.

The problem is that I only want the RowContextMenu to be shown only in the mastertable - not the detailtable.

My initial thought was to differ on the tableview names:

function RowContextMenu(sender, args)
{
    alert(args.get_tableView().get_name());
}

But I can't prevent the contextmenu from showing, by cancelling the firing event.

Suggestions?

The Telerik build is rather old: 2012.1.411.35

Regards,
Anders.

<telerik:RadGrid>
    <%--OMITTED--%>
    <ClientSettings>
        <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
        <Selecting AllowRowSelect="false" />
    </ClientSettings>
    <%--OMITTED--%>
</telerik:RadGrid>
<telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnItemClick="RadContextMenu1_ItemClick">
    <Targets>
        <telerik:ContextMenuControlTarget ControlID="RadGrid1" />
    </Targets>
    <CollapseAnimation Duration="200" Type="OutQuint" />
    <Items>
        <telerik:RadMenuItem runat="server" Text="Kopier">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem runat="server" Text="Slet" Enabled="False">
        </telerik:RadMenuItem>
    </Items>
</telerik:RadContextMenu>

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 28 Oct 2014, 01:55 PM
Hi Anders,

Preventing the menu from displaying is possible by canceling the OnClientShowing event. That said you can try something like this.

ASPX:
<telerik:RadContextMenu ID="RadContextMenu1" OnClientShowing="showing" runat="server">
            <Targets>
                <telerik:ContextMenuControlTarget ControlID="RadGrid1" />
            </Targets>
            <CollapseAnimation Duration="200" Type="OutQuint" />
            <Items>
                <telerik:RadMenuItem runat="server" Text="Kopier">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem runat="server" Text="Slet" Enabled="False">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadContextMenu>


JavaScript:
function showing(sender,args) {
                if ($find(Telerik.Web.UI.Grid.GetFirstParentByTagName(args.get_targetElement(),"table").id).get_name() === "ChildTable") {
                    args.set_cancel(true);
                }
            }


Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
aspliid
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or