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

RadWindow HideAll/ShowAll type functionality

4 Answers 98 Views
Window
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 18 Jan 2013, 01:20 PM
I'm working on a desktop like interface using multiple radwindows on a single page. Right now I am trying to add functionality similar to the Windows 7 Show Desktop button that hides all open windows on click, and then restores all the windows on a second click. I have that funcionality working for the most part using minimizeAll() to hide everything and then a call to showAll(), to get the window titlebars back in place, and then a call to restoreAll() to get the windows back to their previous size. 

The problem I am running into is that when a window is closed it is not truly destroyed. Therefore when I go to show my windows again the closed window comes back. I know I can switch the DestroyOnClose flag to true for the windows, which does solve this issue, but it breaks my event handlers for the close event on all other windows. When a window is created a set a handler for many events, close being one of them, like so:
oWnd.add_close(function (sender, args) {
        windowHandler(sender, "close");
    });
This allows all windows to use my handler function which essentially takes the window information (title, url, x, y, width, height) and saves them for later use. That all works fine until I turn DestroyOnClose to true. Once that is done, only the first window closed executes the handler. Any window closed after that ignores the handler entirely as if the binding for that even was destroyed for all windows, not just the window being closed. 

Is there something I can do to solve either one of these issues so that both pieces of the functionality work?

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 22 Jan 2013, 10:51 AM
Hello Corey,

You can get all windows, loop through them and restore() the ones that are not closed, e.g.:
var manager = $find("<%=myManager.ClientID %>");
var wndCollection = manager.get_windows();
for (var i = 0; i < wndCollection.length; i++)
{
    if (!wndCollection[i].isClosed())
    {
        wndCollection[i].restore();
    }
}



Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Corey
Top achievements
Rank 1
answered on 22 Jan 2013, 01:32 PM
I had already tried this and found the issue to be that the isClosed flag is set to true even for a minimized window. So the functionality breaks all together as no window gets restored. Below is the code that I tried for reference.

for (var i = 0; i < windows.length; i++) {
    if (!windows[i].isClosed()) {
        windows[i].show();
        windows[i].restore();
        sessionStorage.showFlag = 1;
        $("#minMaxWindows img").attr("src", "images/icon_monitor_hide.png");
    }
}

The isClosed flag was my initial thought for all of this, but that flag is set to true for more than just a window that has been closed. Is this a bug in the system that needs to be, or has been fixed? Currently I'm using version 2012.2.607.40.
0
Marin Bratanov
Telerik team
answered on 24 Jan 2013, 09:03 AM
Hi Corey,

How exactly are you minimizing the RadWindows? I have just tried this and it seems to be working as expected on my end. You can find attached my test page and a video with the expected behavior on my end. Could you compare it with your page and try to find the difference?

Regardless of that I can suggest another way of doing this - raise a custom flag in the RadWindow's object when minimizing it (the OnClientCommand event can be used for this, when the ccommandName is Minimize), then check for that flag in the loop and only restore() according to it. Then reset the flag.


Greetings,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Corey
Top achievements
Rank 1
answered on 24 Jan 2013, 02:07 PM
Below is the function I use to show/hide the windows. This is triggered by a click on an icon in the UI.

function toggleAllWindows() {
    var wndManager = GetRadWindowManager();
    if (wndManager.get_windows().length > 0) {
        if (sessionStorage.showFlag != 0) {
            wndManager.minimizeAll();
            sessionStorage.showFlag = 0;
            $("#minMaxWindows img").attr("src", "images/icon_monitor_show.png");
        }
        else if (sessionStorage.showFlag == 0) {
            var windows = wndManager.get_windows();
            for (var i = 0, len ; i < windows.length; i++) {
                if (jQuery(windows[i]).attr("data-state") !== "destroyed") {
                    windows[i].show();
                    windows[i].restore();
                    sessionStorage.showFlag = 1;
                    $("#minMaxWindows img").attr("src", "images/icon_monitor_hide.png");
                }
            }
        }
    }
}

I am now adding a custom attribute to the windows as they are closed out of the UI to use as a flag for detecting what has been closed by the user. This would be along the lines of your suggestion, but it still seems odd that the isClosed flag is only properly set when destroyOnClose is true. 

This workaround is acceptable though so I should be all set here. 
Tags
Window
Asked by
Corey
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Corey
Top achievements
Rank 1
Share this question
or