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

RadContextMenu's showAt() breaks

1 Answer 35 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Prachi
Top achievements
Rank 1
Prachi asked on 22 Aug 2014, 02:21 PM
Hi,

I am using Teleriks' 2014.2.618 version. Earlier, I was using 2012 ones. 

I have ContextMenu on RadGrid which is suppose to open a menu. It worked perfectly fine on 2012 version. However, on 2014, the ContextMenu doesn't open up. While debugging our javascript its breaks at contextmenu.showAt(100,100). 

We verified the passing parameter as integer. We pass the RadGrid's Id as sClientId.

It throws error as : Unable to get property 'showAt' of undefined or null reference 

var x = 0;
var y = 0;

function showMenu()
        x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;

        var contextMenu = $find(sClientId);
        contextMenu.showAt(x, y);
}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 25 Aug 2014, 07:04 AM
Hi Prachi,

Unfortunately I couldn't replicate the issue at my end. Please try the below sample code snippet which works fine at my end.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None"
    AllowSorting="True" AllowPaging="True" PageSize="50" Width="900px">
    <ClientSettings>
        <ClientEvents OnRowContextMenu="RowContextMenu" />
        <Selecting AllowRowSelect="true" />
        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2">
        </Scrolling>
    </ClientSettings>
    <HeaderStyle Width="225px"></HeaderStyle>
    <PagerStyle PageSizeControlType="RadDropDownList" Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
<telerik:RadContextMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true"
    EnableShadows="true">
    <Items>
        <telerik:RadMenuItem Text="Quick view">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Add" Value="add">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Edit" Value="edit">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Delete" Value="delete">
        </telerik:RadMenuItem>
    </Items>
</telerik:RadContextMenu>

Javascript:
function RowContextMenu(sender, eventArgs) {
    var x = 0, y = 0;
    var menu = $find("<%=RadMenu1.ClientID %>");
    var evt = eventArgs.get_domEvent();
    x = evt.rawEvent.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    y = evt.rawEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    menu.showAt(x, y);
}

Thanks,
Shinu.
Tags
Menu
Asked by
Prachi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or