RadWindow HideAll/ShowAll type functionality

5 posts, 0 answers
  1. Corey
    Corey avatar
    7 posts
    Member since:
    Jan 2013

    Posted 18 Jan 2013 Link to this post

    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?
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 22 Jan 2013 Link to this post

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

    Posted 22 Jan 2013 Link to this post

    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.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 24 Jan 2013 Link to this post

    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.
  6. Corey
    Corey avatar
    7 posts
    Member since:
    Jan 2013

    Posted 24 Jan 2013 Link to this post

    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. 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017