find multiple windows

3 posts, 0 answers
  1. mabs
    mabs avatar
    57 posts
    Member since:
    May 2010

    Posted 01 Oct 2010 Link to this post

    I have a page where It is possible to luanceh more than one radwindow, I am creating these windows in the following way,
    var popup = window.radopen(Url, null);
    The user can click a button which will open window 'a', they can then do something else that will cause window 'b' to open.  When in window 'b' I would like to get hold of window 'a' to refresh the content.  I would guess a way to find this is to find the window which is not selected, which would be window 'a'.  I have no idea on how to do this, I can only seem to get hold of the current window when using GetRadWindow()
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }
    Any suggestions would be much appreciated.
  2. mabs
    mabs avatar
    57 posts
    Member since:
    May 2010

    Posted 01 Oct 2010 Link to this post

    sorted, record the windows id's on creation, then you can reference them.
  3. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 04 Oct 2010 Link to this post

    Hi Russell,

    Basically, you could use the get_windows() method of the RadWindowManager to get a reference to a specific RadWindow. For example, the code bellow will close all RadWindows on the page, except the active one:

    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
    <script type="text/javascript">
        function closeAllButActive()
        {
            var windowManager = GetRadWindowManager();
            var allWindows = windowManager.get_windows();
     
     
            for (var i = 0; i < allWindows.length; i++)
            {
                var currentWindow = allWindows[i];
                if (!currentWindow.isActive())
                {
                    currentWindow.close();
                }
            }
        }
     
        function openWin()
        {
            radopen("http://google.com", null);
        }
    </script>
    <button onclick="openWin(); return false;">
        open RadWindows</button>
    <button onclick="closeAllButActive(); return false;">
        Close all but the active RadWindow</button>
    </form>
    </body>
    </html>

    Note that the closeAllButActive() function should be in the parent page, where the RadWindowManager is.

    Kind regards,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top