Get RadGrid cell value using Context menu

3 posts, 1 answers
  1. Fred Mare
    Fred Mare avatar
    36 posts
    Member since:
    Dec 2009

    Posted 26 Jan 2012 Link to this post

    Hi

    I would like to get a radgrid cells value and controls when a context menu item is selected on the client side. How would I do this?

    Thank You
    Fred
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 27 Jan 2012 Link to this post

    Hi,

    You can use a client-side approach to populate the details for a row. With this online demo, try the following modifications:
    <telerik:RadContextMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick"
           EnableRoundedCorners="true" EnableShadows="true">
           <Items>
               <telerik:RadMenuItem Text="Quick view">
                   <Items>
                       <telerik:RadMenuItem>
                           <ItemTemplate>
                             <div id="productName"></div>
      
                           </ItemTemplate>
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem Text="Add" />
               <telerik:RadMenuItem Text="Edit" />
               <telerik:RadMenuItem Text="Delete" />
           </Items>
       </telerik:RadContextMenu>


    function RowContextMenu(sender, eventArgs) {
                  * * *
      
                   sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);
      
      
                   var selectedRow = sender.get_masterTableView().get_selectedItems()[0];
                   var productName =  sender.get_masterTableView().getCellByColumnUniqueName(selectedRow, "ProductName").innerHTML;          
      
                   $get("productName").innerHTML = productName;         
      
                   menu.show(evt);
      
                  * * *
               }


    Note, that with this approach the columns should be rendered. If you want to make them invisible, you should set their Display property to false.

    Greetings,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fred Mare
    Fred Mare avatar
    36 posts
    Member since:
    Dec 2009

    Posted 05 Feb 2012 Link to this post

    Thank you for the help
Back to Top