This is a migrated thread and some comments may be shown as answers.

How to find RadGrid Cell Value in Client Side OnDoubleClick Event

1 Answer 951 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Vincy
Top achievements
Rank 1
Vincy asked on 11 Mar 2014, 02:41 PM
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.



1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Mar 2014, 04:15 AM
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
Tags
Documentation and Tutorials
Asked by
Vincy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or