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

    Hi,
    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"
                                    Width="916px">

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

     I have a column like this in RadGrid HTML:

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

        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.

    Thanks.



  2. Answer
    Princy
    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.

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

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top