Rad Grid Context Menu not showing up

5 posts, 2 answers
  1. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 04 Apr 2014 Link to this post

    I added Rad Content Menu to Rad grid but when i right click on Grid rows i don't see the menu coming up. Do i have to enable anything ? Please let me know.

    Here is my code:

    <script type="text/javascript">
             function RowContextMenu(index, e)
             {                       
                 var menu = $find("<%=RadMenu1.ClientID %>");
                 
                  var evt = eventArgs.get_domEvent();
                 var menuItem = menu.findItemByText("View");
                menuItem.set_navigateUrl("SalesDashboard.aspx?userType=VP&amp;MetricYear=2014&amp;SalesPerson=IACORP\Jeff.Rodgers");
                menu.show(evt);
                }

         </script>
                                                        

      <telerik:RadGrid ID="RadGrid1" Width="60.5%" runat="server" OnNeedDataSource="radGrid_NeedDataSource"            
                             AutoGenerateColumns="false" GroupingSettings-GroupByFieldsSeparator="" AllowMultiRowEdit="true" OnItemDataBound="RadGrid1_ItemDataBound" OnPreRender="RadGrid1_PreRender" ClientSettings-ClientEvents-OnColumnContextMenu="true" >
                <MasterTableView ShowGroupFooter="false" EditMode="InPlace" DataKeyNames="SalesPerson">
                                      
                    <Columns>              
                                
                     <telerik:GridBoundColumn UniqueName="Jt.Calls" DataField="Jt. Calls" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"  ColumnGroupName="Monthly Activity" HeaderText="Jt. Calls" />
                     <telerik:GridBoundColumn UniqueName="Demos" DataField="Demos" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"  ColumnGroupName="Monthly Activity" HeaderText="Demos" />
                     
                    </Columns>

                    </MasterTableView>
              <ClientSettings>
                <ClientEvents OnRowContextMenu="RowContextMenu" />           
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
            </telerik:RadGrid>
       
     <telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="Vista" EnableRoundedCorners="true" EnableShadows="true" OnItemClick="RadMenu1_ItemClick">
            <Targets>
                   <telerik:ContextMenuControlTarget ControlID="RadGrid1" />
              </Targets>
                <Items>
                 <telerik:RadMenuItem Text="View"  />
         
                </Items>
    </telerik:RadContextMenu>         
                  





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

    Posted 06 Apr 2014 in reply to Neetha Link to this post

    Hi Neetha,

    From your code I have noticed that you are setting OnColumnContextMenu event as true. This event is fired when the user right-clicks arbitrary column header, and it is not good to set an event name as true/false value. Please try to remove that from your code and also do the following modification in your JavaScript which works fine at my end.

    JavaScript:
    function RowContextMenu(index, e) {
        var menu = $find("<%=RadMenu1.ClientID %>");
        var evt = e.get_domEvent();
        //your code
        menu.show(evt);
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 08 Apr 2014 in reply to Shinu Link to this post

    Thanks this worked.

    Also I have to pass parameters to set_navigateURL in RowContextMenu, based on which row of a grid user right clicked and click on a menu item. 
    RadGrid have loginname and metric year columns which are set to display false and i have to pass these two values to navigate url

    Please let me know.





  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Apr 2014 in reply to Neetha Link to this post

    Hi Neetha,

    Please try the following JavaScript which works fine at my end.

    JavaScript:
    var OrderID, EmployeeID;
    function OnClientItemClicked(sender, args) {
        //itemclicked event of radcontextmenu
        var grid = $find("<%=RadGrid1.ClientID %>");
        var selectedRow = grid.get_masterTableView().get_selectedItems()[0];
        var OrderID = grid.get_masterTableView().getCellByColumnUniqueName(selectedRow, "OrderID").innerHTML;
        EmployeeID = grid.get_masterTableView().getCellByColumnUniqueName(selectedRow, "EmployeeID").innerHTML;
        //navigating to new page along with the values from grid
        args.get_item().set_navigateUrl("Default5.aspx?OrderID=" + OrderID + "&EmployeeID=" + EmployeeID);
    }
    function RowContextMenu(sender, eventArgs) {
        var menu = $find("<%=RadMenu1.ClientID %>");
        var evt = eventArgs.get_domEvent();
        var index = eventArgs.get_itemIndexHierarchical();
        sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);
        var selectedRow = sender.get_masterTableView().get_selectedItems()[0];
        OrderID = sender.get_masterTableView().getCellByColumnUniqueName(selectedRow, "OrderID").innerHTML;
        EmployeeID = sender.get_masterTableView().getCellByColumnUniqueName(selectedRow, "EmployeeId").innerHTML;
        menu.show(evt);
        evt.cancelBubble = true;
        evt.returnValue = false;
        if (evt.stopPropagation) {
            evt.stopPropagation();
            evt.preventDefault();
        }
    }

    Default5.ASPX.CS(Navigated Page):
    protected void Page_Load(object sender, EventArgs e)
    {
        string value1 = Request.QueryString["OrderID"];
        string value2 = Request.QueryString["EmployeeID"];
    }

    Thanks,
    Shinu.
  6. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 09 Apr 2014 in reply to Shinu Link to this post

    Thanks .. this worked.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017