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

Get radgrid data from javascript

5 Answers 415 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 15 Oct 2008, 11:21 PM
Here is my grid:

 <telerik:RadGrid runat="server" ID="radTableColumns" AutoGenerateColumns="false" AllowMultiRowSelection="true" > 
            <ClientSettings> 
                <Selecting AllowRowSelect="true" /> 
            </ClientSettings> 
            <MasterTableView> 
            <Columns> 
                <telerik:GridClientSelectColumn HeaderStyle-Width="40px"   /> 
               <telerik:GridBoundColumn DataField="column_name" HeaderText="Column Name" /> 
                <telerik:GridBoundColumn DataField="column_type" HeaderText="Column Type" /> 
            </Columns> 
            </MasterTableView> 
             </telerik:RadGrid> 

It's in a radwindow, so I need to be able to loop through the grid and compile a list of items where the checkbox is checked. 

I saw the example where you can set it to postback on the check changed event, but I'd prefer not to have to rebuild the string and postback everytime something is checked.

Is there anyway to do a loop through in javascript?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 16 Oct 2008, 03:47 AM
Hi Angie,

Here is the javascript code to loop through the selected rows in a Grid.

ASPX:
 <INPUT onclick="GetSelectedNames();"  type="button" value="Get selected rows contact names"

JS:
  function GetSelectedNames() 
 { 
   var grid = $find("<%=RadGrid1.ClientID %>"); 
   var MasterTable = grid.get_masterTableView(); 
 
   var selectedRows = MasterTable.get_selectedItems(); 
   for (var i = 0; i < selectedRows.length; i++) 
   { 
     var row = selectedRows[i]; 
     var cell = MasterTable.getCellByColumnUniqueName(row, "CategoryID") 
    //here cell.innerHTML holds the value of the cell 
   } 
 } 


Thanks
Shinu
0
Angie
Top achievements
Rank 1
answered on 16 Oct 2008, 06:58 PM
Thank you Shinu.  That's exactly what I needed.
0
Shinu
Top achievements
Rank 1
answered on 17 Oct 2008, 05:06 AM
Hi Angie,

You can also go through the following help articles to get more details on this regard.
Getting cell values for selected rows client side
Extracting key values client-side

Thanks
Shinu.
0
Kervin
Top achievements
Rank 1
answered on 11 Nov 2008, 05:38 AM
Thanks!!
0
Kavya
Top achievements
Rank 2
answered on 06 Sep 2011, 07:31 PM
Shinu

I tried to use
grid.get_masterTableView(); 
 
but it gives me object not found error.

Please let me know what i can do to get the all items from radgrid. When i check the DLL file for Radgrid it shows version 5.1.5.

Not sure if the above function is valid for this version . Please help

Thank you
kavya
Tags
Grid
Asked by
Angie
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Angie
Top achievements
Rank 1
Kervin
Top achievements
Rank 1
Kavya
Top achievements
Rank 2
Share this question
or