How to find RadGrid Cell Value in Client Side OnDoubleClick Event

2 posts, 1 answers
  1. Vincy
    Vincy avatar
    10 posts
    Member since:
    Aug 2013

    Posted 11 Mar 2014 Link to this post

    I have a RadGrid like this: (only selective code is shown here for clarity..please bear)

     <telerik:RadGrid ID="MessageView" runat="server" AllowPaging="True" PageSize="50"
                                    OnGroupsChanging="MessageView_GroupsChanging" OnNeedDataSource="MessageView_NeedDataSource"
                                    AllowSorting="true" ShowGroupPanel="true" AutoGenerateColumns="False" GridLines="None"
                                    OnItemDataBound="MessageView_ItemDataBound" OnItemCommand="MessageView_ItemCommand"

      <ClientEvents OnRowDblClick="MessageViewDoubleClick"></ClientEvents>

     I have a column like this in RadGrid HTML:

        <telerik:GridTemplateColumn UniqueName="CustomerName">
                                                    <asp:Label ID="hdnLblCustomerName" Style="visibility: hidden;" runat="server"></asp:Label>

        ON SERVER SIDE... I am assigning the value to this label in  MessageView_ItemDataBound event  like this:
                       Label hdnLblCustomerName = (Label)e.Item.FindControl("hdnLblCustomerName");
                       hdnLblCustomerName.Value = Convert.ToString(dt.Rows[0]["CustomerName"]);

    NOW, In the Client Side , i have written like this:

     function   MessageViewDoubleClick(sender, args) 
                       var dataItem = $get(args.get_id());
                        var grid = sender;
                        var MasterTable = grid.get_masterTableView();
                        var row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
                        var cell = MasterTable.getCellByColumnUniqueName(row, "CustomerName");
                        var lblvalue = cell.innerHTML;

    Till here everything is going right, my label got assigned with the correct value...and now I have to fetch this on the client side
    BUT , now the problem is
     lblvalue is showing value like this
       <span id="MessageView_ctl00_ctl04_hdnLblCustomerName" style="visibility:hidden;">John</span>

    but I need only "John" .

    Please suggest how to achieve this.


  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2014 in reply to Vincy Link to this post

    Hi Vincy,

    You can try using innerText to get the value of the label in Grid.

    var cell = MasterTable.getCellByColumnUniqueName(row, "CustomerName");
    var lblvalue = cell.innerText; // Get the label text

Back to Top