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

Pass back RadGrid selected row to Parent

3 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
nav100
Top achievements
Rank 1
nav100 asked on 12 Oct 2011, 05:37 PM
I have a RadWindow which shows results in Radgrid. I need to pass back the selected row values from the Grid back to the Parent page. How can I do this? If it is not possible what is the best way to achieve this? I have to close the modal window and fill the parent page text fields after clicking on the grid row. Any input is appreciated.

3 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 12 Oct 2011, 08:28 PM
Hi,

This is what I do:

In the RadWindow, I process the click event on a button (client-side). I get all of the data I need from the selected rows and put it in an array.

I then use JSON to serialize the data and pass it back to the calling page as the argument to the .close() method of the RadWindow.

In my calling page, I pass the argument collected in the OnClientClose client-side event of the RadWindow to an AjaxRequest. The event handler in the code-behind, deserializes the data passed in as the AjaxRequest argument and there you go, you have an array of objects each of which represents the data collected from a selected row in the grid in the RadWindow.

I'd post examples, but, in this case, I can't and I don't have the time to write something fresh, but hopefully there's enough info here for you to work your way through it.

-- 
Stuart
0
nav100
Top achievements
Rank 1
answered on 12 Oct 2011, 08:43 PM
Thanks Stuart. Is there any code example to get the selected row data and put it in Array on the client side?
0
Stuart Hemming
Top achievements
Rank 2
answered on 12 Oct 2011, 11:52 PM
I can't promise that the following code will work out-of-the-box as I'm working with only access to a text editor and the online help files, but this is the general idea.

var result = new Array();
var grid = $find("<%= RadGrid1.ClientID %>");
var selectedRows = grid.get_selectedItems();
for(var i=0; i<selectedRows.length; i++)
{
  var o = new Object();
  o.FirstItem = selectedRows[i].getDataKeyValue("FirstField");
  o.SecondItem = selectedRows[i].getDataKeyValue("SecondField");
  //o.SomeOtherThing = some calculation or value added item, whatever yo want
  result[i] = o;
}
return result;

I'm sure that a grown-up will be along to point out any errors, but that should get you going.

-- 
Stuart
Please remember to mark the reply as an Answer if it's helpful.
Tags
General Discussions
Asked by
nav100
Top achievements
Rank 1
Answers by
Stuart Hemming
Top achievements
Rank 2
nav100
Top achievements
Rank 1
Share this question
or