Opening a child RadWindow from a parent RadWindow

3 posts, 0 answers
  1. Marja
    Marja avatar
    70 posts
    Member since:
    Nov 2013

    Posted 04 Dec 2013 Link to this post

    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. Marja
    Marja avatar
    70 posts
    Member since:
    Nov 2013

    Posted 04 Dec 2013 Link to this post

    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).
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marja
    Marja avatar
    70 posts
    Member since:
    Nov 2013

    Posted 05 Dec 2013 Link to this post

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