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

Loop Grid Controls from client side

4 Answers 276 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 2
Rahul asked on 09 Dec 2011, 06:01 AM
Hi,
    How can i loop through all the controls in a grid(in all rows) and find the type of the control(eg: Radio button or check box) from client side using javascript

 Rahul R

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Dec 2011, 06:09 AM
Hello Rahul,

Try the following javascript.
JS:
function Click()
{
  var grid = $find("<%=RadGrid1.ClientID %>");
  var masterTable = grid.get_masterTableView();
  var rows = masterTable.get_dataItems();
  for (var i = 0; i < rows.length; i++)
  {
   var chk = rows[i].findElement("CheckBox1");
  }
}

-Shinu.
0
Rahul
Top achievements
Rank 2
answered on 09 Dec 2011, 06:24 AM
Hi Shinu,

That works.

Thanks.
Rahul R
0
Margo Noreen
Top achievements
Rank 1
Iron
Veteran
answered on 17 Feb 2012, 09:05 PM
Hello Shinu --

Just one more detail... how do you get to the controls in the header row?

I have a radgrid on  a page and the first column is a GridTemplateColumn.  The HeaderTemplate subelement contains an asp:CheckBox control.  The ItemTemplate subelement also contains a checkbox. 

I'd like to use the loop you provided to set the value of all the rows' checkboxes to the state of the checkbox in the header row.  So far, I've not been able to figure out how to get at that...

Thanks so much.


0
Richard
Top achievements
Rank 1
answered on 21 Feb 2012, 05:40 PM
Margo:

Take a look at the Grid/Column Types online demo. The first column of the top RadGrid has the functionality that you seek built in at design time using the telerik:GridClientSelectColumn type.

You can also refer to the GridClientSelectColumn - select all rows with enabled check boxes only Code Library project that "demonstrates how to disable specific checkboxes in GridClientSelectColumn so that the end-users won't be able to change their status on the client. By default the header checkbox, however, will still select all data rows, no matter whether the corresponding rows check box is enabled or not. For this purpose the OnRowSelecting client event is used to cancel the selection for each row where the check box is disabled."

Hope this helps!
Tags
Grid
Asked by
Rahul
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Rahul
Top achievements
Rank 2
Margo Noreen
Top achievements
Rank 1
Iron
Veteran
Richard
Top achievements
Rank 1
Share this question
or