Pass back RadGrid selected row to Parent

4 posts, 0 answers
  1. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 12 Oct 2011 Link to this post

    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.
  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 12 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 12 Oct 2011 Link to this post

    Thanks Stuart. Is there any code example to get the selected row data and put it in Array on the client side?
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 12 Oct 2011 Link to this post

    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.
Back to Top