Updating Window From Another Window

9 posts, 0 answers
  1. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 29 Jun 2009 Link to this post

    I am currently launching a window (named "rwAttachmentsMaster" in the example below) from within a window (named "rwRequestMasterpage" in the example below), and trying to get it to update the first window when the second window is closed, without much luck.

    I have both windows declared in a window manager, which is in my masterpage, and am using the following code -

    function LaunchAttachments() {  
            var parent = GetRadWindow().BrowserWindow;  
            var attach = parent.radopen("Attachments.aspx""rwAttachmentsMaster");  
            setTimeout(function() { attach.setActive(true); }, 100);  
            attach.add_close(function() { UpdateAttachmentCount(); });  
        }  
     
        function UpdateAttachmentCount() {  
            var requestWindow = GetRadWindowManager().BrowserWindow.getWindowById("rwRequestMasterpage");  
            requestWindow.get_contentFrame().contentWindow.UpdateAttachmentCountStep2();  
        }  
     
        function UpdateAttachmentCountStep2() {  
            var label = document.getElementById("<%= lblNumAttachments.ClientID %>");  
            label.value = "x";  
        } 

    All of that code is currently sitting in the page you get when you open the first window. I'm not entirely sure if that is where it is all meant to go or not.
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 30 Jun 2009 Link to this post

    Hi Peter,

    I suggest to examine closely the Returning Values from a Dialog demo on our site - it shows the same scenario that you wish to implement. If you still experience problems after that, just open a support ticket and send us your implementation so we could check it.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 01 Jul 2009 Link to this post

    That demo works great, and has enabled me to achieve my functionality, but it has uncovered a new problem with it.

    In the demo, Dialogue2 is closed via a button, which runs the following script (slightly adapted to meet my needs) -

    function UpdateAttachmentsCount() {  
            //Get a reference to the parent page (Default.aspx)   
            var oWnd = GetRadWindow();  
     
            if (getQstring("updateattachments""") != "") { // the getQstring function simply gets a querystring value  
                //get a reference to the second RadWindow  
                var dialog1 = oWnd.get_windowManager().getWindowByName(getQstring("updateattachments"));  
     
                // Get a reference to the first RadWindow's content  
                var contentWin = dialog1.get_contentFrame().contentWindow  
     
                //Call the predefined function in Dialog1  
                contentWin.UpdateAttachmentCount(document.getElementById("<%= hfRowCount.ClientID %>").value);  
            }  
              
            //Close the second RadWindow  
            oWnd.close();  
        } 

    Now, this works great as a button, but if I try to assign that function to the close button via add_close(), it does not work. How would I go about getting the same functionality to occur when pressing the X in the corner of the window?

    So, in summary, I am trying to accomplish the following -

    Open Window1 from MainPage (which I can do fine)
    Open Window2 from Window1 (which I can do fine)
    Click X button in corner of Window2 and have it pass back info to Window1 (this produces errors)
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 02 Jul 2009 Link to this post

    Hello Peter,

    I attached to this thread a small sample that shows how to achieve the desired result - I hope this helps.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 02 Jul 2009 Link to this post

    Thank you, Georgi. Everything is working perfectly now.
  6. Antony
    Antony avatar
    57 posts
    Member since:
    Oct 2008

    Posted 17 Jul 2009 Link to this post

    Hi Everyone,

    I have a similiar situation:

    I have a MasterPage which contains a RadWindowManager() and a javascript function "UpdateTimeOut()"

    Dialog1 is opened by the Masterpage
    Dialog2 is opened by Dialog1

    I need Dialog2 to call the javascript function on the MasterPage UpdateTimeOut()

    Is this possible?

    I can do this if Dialog2 is opened by MasterPage but not when it's opened by Dialog1.

    Please help
    Thanks
    Antony
  7. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 17 Jul 2009 Link to this post

    Hello Antony,

    If you have opened the second RadWindow in the context of the browser by using the browserWindow property, you can use the same property again to reference the browser and exceute teh javascript function.

    In case you have opened the second RadWindow in the context of the first
    RadWindow, then you can use the keyword top to to reference the browser window and to execute the js function.



    Kind regards,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Antony
    Antony avatar
    57 posts
    Member since:
    Oct 2008

    Posted 17 Jul 2009 Link to this post

    Hi Svetlina,

    Thanks for the quick response, I have tried both methods you suggested and it's still not working.

    The Dialog2 is opened using the RadEditor.ShowExternalDialog so I'm not sure quite what the context is.

    Any further ideas would be appreciated

    Thanks
    Antony
  9. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Jul 2009 Link to this post

    Hello Antony,

    To be able to help we need to have a closer look over your exact setup and logic. Please open a support ticket and send us your implementation so we could check it.


    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top