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

Find and Set ComboBox Value inside a Grid

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JustinWong
Top achievements
Rank 1
JustinWong asked on 27 Dec 2008, 11:07 PM
Hi:

I have a grid with 4 template columns, each with 1 or 2 RadComboBox in them.  At some point in time, (e.g.: when user click a hyperlink with href="javascript:DoSomething()"), I need to:

1. Scroll through the rows of the Grid,
2. Find a RadComboBox that is in a particular column, and
3. Get and/or Set the selectedIndex of the RadComboBox.

I need to do this using javascript on client-side. Note that the grid is in display mode with the RadCombo already there. It is NOT in edit mode. I was not able to find any example that would do this, and would appreciate some help on this.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2008, 07:17 AM
Hello Justin,

On clicking the link, you can loop through the rows in the grid using the following Javascript code:
js:
function DoSomething() 
  var grid = $find("<%=RadGrid1.ClientID %>"); 
  var MasterTable = grid.get_masterTableView(); 
  var Rows = MasterTable.get_dataItems(); 
  for (var i = 0; i < Rows.length; i++) 
   { 
     var row = Rows[i];   
     // access the combobox    
   } 
 

To access controls in the TemplateColumn of the grid on the client, you can refer to the following code library submission.
Accessing server controls in a grid template on the client
Once you access the combobox, you should be able to set its selected index.

Hope this guides you to the right track.
Thanks
Princy.
0
JustinWong
Top achievements
Rank 1
answered on 01 Jan 2009, 01:27 AM

Thanks Princy. That was an excellent reference you provided. It's much appreciated!

 

Justin

Tags
Grid
Asked by
JustinWong
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
JustinWong
Top achievements
Rank 1
Share this question
or