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

Keeping RadWindow Closed When Closed!

2 Answers 111 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 30 Aug 2011, 12:22 AM
Hi Telerik,

As a disclaimer, this question is vague. My issue is that, under certain conditions, a RadWindow will re-open itself and become non-responsive to user interaction. For instance, if I have some client-side code which is executing (may or may not center the RadWindow), and the user closes the window before this code finishes executing. Then, when the code finishes executing, the window pops back open! If the user clicks on the 'X' it does not close the window.

I suspect this is entirely my fault... possibly should not allow closing of the window until fully loaded, or find a way to cancel client-side script execution. Regardless, I was looking for a blanket fix to make sure this problem doesn't accidentally rear its head to a customer.

At this point, I'm doing something like this:

//This will only trigger when the browser window resizes.
//Fix the display of the dashboard, if theres an open window, re-center it.
function OnMainSplitterResizing() {
    displayOverBaseID = baseSplitterID;
 
    if (oWindow && oWindow.isVisible) oWindow.center();
}

In this scenario, I handle the browser window resizing. If there is an open window, I would like to move it back to the center of the page. It is my impression that calling oWindow.center on an element which is defined, but not visible, is dangerous in that it may show the window again?

Does what I'm doing make sense? Have you heard of other users experiencing similar issues / is there a standard way of handling this? Or is it just "code better and not defensively" and make sure that the state of my window is such that at any point in time, if its closed, it can respond intuitively.

Cheers,

Sean

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 31 Aug 2011, 12:31 PM
Hello Sean,

The only case where we have seen this issue is if the RadWindow is updated via an AJAX request while it is being loaded. What happens is that the HTML is created, but the disposing and reattaching of the events is interrupted by the markup update that comes with the AJAX response.

That means that if you are using a RadWindow with a ContentTemplate, a button inside initiates an AJAX request and the entire RadWindow is wrapped in the update panel this behavior may be observed. To avoid this you should properly ajaxify the RadWindow, as explained in this help article (i.e. keep the update panels inside the ContentTemplate).

If that is not the case in your scenario I am not sure what may be causing this, but it should be related to an incorrect disposing of the RadWindow object.

As for calling the center() method of a RadWindow that is not shown - indeed this should not be done, so your check is in place and I do not believe this is the cause of the issue, yet you may test if removing it resolves the situation and does not break the RadWindow somehow. If so - go without it.

Kind regards,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Sean
Top achievements
Rank 2
answered on 06 Sep 2011, 10:25 PM
Hi Telerik,

Thank you for your informative response. I will keep these concepts in mind for future programming endeavors. Regarding my issue, I did find a solution, but I am not quite sure why the solution worked. I'll just provide the scenario / fix in case anyone experiences this problem in the future.

Scenario: RadWindow re-opens itself upon centering.
Setup:
<telerik:RadWindow ID="ReportWindow" Runat="Server" Title="CableSolve Report Viewer" Width="600" Height="500" />

This is how my RadWindow is declared. This window is opened off of a RadDock's custom command by firing client-side code:

//Opens the Custom Report Viewer window using the dock's reportID as a parameter to display appropriate data.
function OpenReport(dock) {
    var fullURL = window.reportViewerURL + dock.get_element().getAttribute("ReportID");
    oWindow = window.radopen(fullURL, "ReportWindow");
}

The URL points to an MVC page on our web application.

Now, with the above code, if the window is opened, closed, and then this method is executed:

//This will only trigger when the browser window resizes.
//Fix the display of the dashboard, if theres an open window, re-center it.
function OnMainSplitterResizing() {
    displayOverBaseID = baseSplitterID;
    if (oWindow && oWindow.isVisible) oWindow.center();
}

Even though the window has been closed, this state information is not written back to the oWindow variable (presumed by me). As such, the seemingly fail-safe code "oWindow && oWindow.isVisible" fails to fend-off this undesireable scenario.

Solution:

<telerik:RadWindow ID="ReportWindow" Runat="Server" Title="CableSolve Report Viewer" Width="600" Height="500" OnClientClose="OnReportWindowClose" />

function OnReportWindowClose(dialogWindow) {
    oWindow = null;
}

This allows us to still maintain a reference to our open window (in case it needs to be re-centered), but also prevents the window from being made visible after previously being invisible.

Cheers,

Sean
Tags
Window
Asked by
Sean
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Sean
Top achievements
Rank 2
Share this question
or