JavaScript error when retrieving context menu

4 posts, 0 answers
  1. Menna
    Menna avatar
    5 posts
    Member since:
    Jul 2008

    Posted 08 Jul 2008 Link to this post

     i am working with trial version of Rad Controls for Asp.NET AJAX. and migrating from ASP controls.I am supposed to evaluate the needed changes and the telerik controls for future purchasing, but unfortunately i have two problems with the rad menu, I am using rad grid and attaching context menu to it on RowContextMenu  event which is handled by javascript fn.
    First problem:
    The index is always object
    The menu var is always object and an error: "object doesn't support method or property"
    Here's my html Code
    Thanks in advance

    <script language="javascript" >
              function RowContextMenu( index,e)
                      document.getElementById("radGridClickedRowIndex").value = index;
                      var menu = <%= gvBrowseContextMenu.ClientID %>;

                    e.cancelBubble = true;
                    e.returnValue = false;

                    if (e.stopPropagation)
                    this.SelectRow(this.Rows[1].Control, true);

    <telerik:RadContextMenu ID="gvBrowseContextMenu" runat= "server" IsContext="True" Skin="Outlook"  ExpandDelay="10" OnItemClick="gvBrowseContextMenu_OnItemClick" ContextMenuElementID="none">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                                <telerik:RadMenuItem runat="server" Text="Edit">
                                <telerik:RadMenuItem runat="server" Text="Delete">
                    <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
                    <telerik:RadGrid ID="gvBrowse" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
                        AllowSorting="True" BorderWidth="0px" CellSpacing="1" GridLines="None" Height="217px"
                        MasterTableView-DataKeyNames="InvoiceNumber" OnPageIndexChanged="gvBrowse_PageIndexChanging"
                        OnPreRender="gvBrowse_PreRender" PagerStyle-CssClass="es_grid_pager" ShowStatusBar="True"
                        Skin="Office2007" Width="249%" OnNeedDataSource="gvBrowse_NeedDataSource" ShowGroupPanel="True">
                        <PagerStyle CssClass="es_grid_pager" Mode="NextPrevAndNumeric" />
                        <MasterTableView DataKeyNames="InvoiceNumber">
                            <RowIndicatorColumn Visible="False">
                                <HeaderStyle Width="20px" />
                            <ExpandCollapseColumn Resizable="False" Visible="False">
                                <HeaderStyle Width="20px" />
                                <PopUpSettings ScrollBars="None" />
                                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="false" />
                        <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True">
                            <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
                            <Selecting AllowRowSelect="True" />
  2. Erjan Gavalji
    Erjan Gavalji avatar
    1455 posts

    Posted 08 Jul 2008 Link to this post

    Hi Menna,

    The correct syntax of the  RowContextMenu client-side event handler of RadGrid for ASP.NET Ajax is function rowContextMenu(sender, args). You should use the get_itemIndexHierarchical() client-side property to identify the item index. You can get a reference to the RadMenu client-side object by using the $find() global function.

    Following your example:
    function rowContextMenu(sender, args)
        var index = args.get_itemIndexHierarchical();

        document.getElementById("radGridClickedRowIndex").value = index;
        var menu = $find("<%= gvBrowseContextMenu.ClientID %>");

    Please, check the online examples, I believe they will help you get started with using RadControls for ASP.NET Ajax. You might also find the Online Documentation useful.

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 09 Jul 2008 Link to this post

    Hello Menna,

    Once you have the index of the row, you can select the row like this:

       var masterTable = sender.get_masterTableView();
       //select the current row

    Also, you might find these links useful:

    I hope this helps.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top