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

Opening a child RadWindow from a parent RadWindow

2 Answers 52 Views
Window
This is a migrated thread and some comments may be shown as answers.
Marja
Top achievements
Rank 1
Marja asked on 04 Dec 2013, 10:19 PM
I've read the information at http://www.telerik.com/help/aspnet-ajax/window-programming-opening-from-within-dialog.html and I'm now trying to let the child RadWindow 'talk' back to its parent RadWindow.

When the user presses OK in the child window, a function in the parent RadWindow should be called, passing one or more arguments.

I've tried using 'opener' in the child RadWindow to reference the parent RadWindow, but it is undefined.

I've tried explicitly specifying a parent property the following way:
function OpenChildRadWindow(p_sURL, p_iWidth, p_iHeight) {
    var l_oBrowserWnd = GetRadWindow().BrowserWindow;
    setTimeout(function () {
        var l_oWindow = l_oBrowserWnd.radopen(p_sURL, "newRadWindow", p_iWidth, p_iHeight);
        l_oWindow.radParent = this;
        l_oWindow.InitialBehaviors = Telerik.Web.UI.WindowBehaviors.None;
        l_oWindow.set_modal(true);
    }, 0);
}
But when I try to reference "window.radParent" in the child RadWindow it is also undefined.

How can I let a parent and child RadWindow communicate with each other?

2 Answers, 1 is accepted

Sort by
0
Marja
Top achievements
Rank 1
answered on 04 Dec 2013, 10:57 PM
Extra info:
The first RadWindow is opened from RadEditor using "editor.showExternalDialog". And that first Radwindow needs to open a second RadWindow.
And then the second RadWindow needs to communicate with its originating 'opener' RadWindow (being the custom editor dialog).
0
Marja
Top achievements
Rank 1
answered on 05 Dec 2013, 09:49 AM
I've managed to get this mechanism working.

In the parent RadWindow (the one opened from RadEditor using "editor.showExternalDialog"), I have the following:

function OpenChildRadWindow(p_sURL, p_iWidth, p_iHeight) {
    var l_oBrowserWnd = GetRadWindow().BrowserWindow;
    var l_oWindowManager = l_oBrowserWnd.GetRadWindowManager();
    var l_oActiveWind = l_oWindowManager.getActiveWindow();
    setTimeout(function () {
        var l_oDialog = l_oBrowserWnd.radopen(p_sURL, "newRadWindow", p_iWidth, p_iHeight);
        l_oDialog.activeParent = l_oActiveWind;
    }, 0);
}

And in the child RadWindow, I now have the following:

function wsReturnValueToParent() {
    //Get a reference to the parent page     
    var oWnd = GetRadWindow();
 
    //get a reference to the originating RadWindow      
    var l_oParent = oWnd.activeParent;
    if (l_oParent) {
        // get a reference to the first RadWindow's content
        var contentWin = l_oParent.get_contentFrame().contentWindow
 
        // call the predefined function in parent dialog
        if (contentWin && contentWin.wsProcessDBPage) {
            var l_oRadio = $('input[name=rdSelect]');
            if (l_oRadio) {
                var l_sPageID = '';
                for (var i = 0; i < l_oRadio.length; i++) {
                    if (l_oRadio[i].checked) {
                        l_sPageID = l_oRadio[i].value;
                        break;
                    }
                }
                var l_sUrl = '?PageID=' + l_sPageID;
                contentWin.wsProcessDBPage(l_sUrl);
            }
        }
    }
    oWnd.close();
}

It's working fine now. :-)
Tags
Window
Asked by
Marja
Top achievements
Rank 1
Answers by
Marja
Top achievements
Rank 1
Share this question
or