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

Getting Column values in Grid on Client side

5 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
A2H
Top achievements
Rank 1
A2H asked on 09 Jul 2010, 05:13 AM
Hi,
    Scenario:
In telerik grid I have six columns,and grid have 1000+ records.Suppose a user select 10 records from this .I want to have a validation in which user had selected right columns or not.For this I have to Get the vlaue of 3 rd column from grid for the selected records and have check  and based on the result i have to show a message.

How can we get the 3rd column value from grid for the selected records.For selecting row i am using client select column

Thanks
A2H

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2010, 06:52 AM
Hello,

I think you want to access cell values of all selected rows from external event such as button click.  If so you can try the following code snippet.

Java Script:
<script type="text/javascript">
    function ButtonClick()
     {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        for (var i = 0; i < MasterTable.get_selectedItems().length; i++)
          {
            var row = MasterTable.get_selectedItems()[i];
            var cellValue = MasterTable.getCellByColumnUniqueName(row, "ColumnUniqueName").innerHTML; // UniqueName of 3rd column
          }
      }
</script>

Thanks,
Princy.
0
A2H
Top achievements
Rank 1
answered on 09 Jul 2010, 09:36 AM
Hi Princy,
           Thanks for ur Reply.

I have used ur code.But its not working.

Column which I need to get the value is  a template column.

Do we need to do some changes in ur code to get values from a template column

Thanks,
A2H
0
A2H
Top achievements
Rank 1
answered on 10 Jul 2010, 06:30 AM
Hi All,
        Please help me .Its very urgent.

Thanks,
A2H
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Jul 2010, 07:14 AM
Hello,

 I guess you are using one Label inside GridTemplateColumn. If so you can use the following code snippet to access the Label control and value.

ASPX:
<telerik:GridTemplateColumn>
    <ItemTemplate>
       <asp:Label ID="Label1" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Java Script:
<script type="text/javascript">
     function ButtonClick()
      {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        for (var i = 0; i < MasterTable.get_selectedItems().length; i++) {
            var cellValue1 = MasterTable.get_selectedItems()[i].findElement("Label1").innerHTML;
       }
    }
</script>

Let me know if you need further assistance.

Thanks,
Princy.
0
A2H
Top achievements
Rank 1
answered on 12 Jul 2010, 02:19 PM
Hi Princy,
    Sample code give me exactly what I needed :).

Thanks a Ton............

Thanks,
A2H
Tags
Grid
Asked by
A2H
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
A2H
Top achievements
Rank 1
Share this question
or