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

Updating Window From Another Window

8 Answers 117 Views
Window
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 30 Jun 2009, 03:16 AM

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.

8 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 30 Jun 2009, 11:06 AM
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.
0
Peter
Top achievements
Rank 1
answered on 02 Jul 2009, 12:05 AM
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)
0
Georgi Tunev
Telerik team
answered on 02 Jul 2009, 10:09 AM
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.
0
Peter
Top achievements
Rank 1
answered on 03 Jul 2009, 04:13 AM
Thank you, Georgi. Everything is working perfectly now.
0
Antony
Top achievements
Rank 1
answered on 17 Jul 2009, 11:47 AM
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
0
Svetlina Anati
Telerik team
answered on 17 Jul 2009, 12:10 PM
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.
0
Antony
Top achievements
Rank 1
answered on 17 Jul 2009, 12:35 PM
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
0
Georgi Tunev
Telerik team
answered on 21 Jul 2009, 11:33 AM
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.
Tags
Window
Asked by
Peter
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Peter
Top achievements
Rank 1
Antony
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or