Launch Window from within Window, and set new Window to be active?

7 posts, 0 answers
  1. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 23 Jun 2009 Link to this post

    Is it possible to guarantee that when you launch a window from within a window, that the new window be set to be the active window?

    After doing some forum reading, it seems that all I should need to do is include the following code to make the new window active -

    setTimeout(function() { attach.setActive(true); }, 0); 

    But this doesn't seem to work properly for me. The odd thing is, it sometimes works, sometimes doesn't. It seems to have a 50% chance of actually becoming the active window.

    Here is my code for launch the window from within a window, and attempting to make it active -

    function LaunchAttachments() {  
            var section = document.getElementById("<%= hfAttachmentsSectionCode.ClientID %>").value;  
            var parent = GetRadWindow().BrowserWindow;  
            var attach = parent.radopen("Attachments.aspx?client=-1&section=" + section, "NewWindow");  
            attach.set_width(800);  
            attach.set_height(400);  
            attach.center();  
            salesRequest.set_status("");  
            attach.set_title("Attachments");  
            setTimeout(function() { attach.setActive(true); }, 0);  
            GetRadWindow().setActive(false);  
        } 
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 24 Jun 2009 Link to this post

    Hi Peter,

    The code that you posted seems OK - try increasing the timeout and see how your app will behave. Also there is no need to explicitly setActive(false) for the current RadWindow.

    If you still experience problems after that, it will be best to open a support ticket and send us a sample project that reproduces the issue - we will check it right away.



    All the best,
    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.
  3. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 25 Jun 2009 Link to this post

    I tried increasing the timeout value to 10, 100, 1000 and 10000 and this still didn't work. I might have to prepare a sample of my code and send it in via a support ticket. Thanks.
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 26 Jun 2009 Link to this post

    OK Peter,

    Once I receive the ticket I will check it and get back to you as soon as possible.

    Regards,
    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.
  5. Peter
    Peter avatar
    95 posts
    Member since:
    Mar 2009

    Posted 29 Jun 2009 Link to this post

    Hmmm, I may not need to submit that ticket afterall. I have now changed how I launch the windows, slightly, and it seems to be working. Rather than using the above code, I am now defining the window within a RadWindowManager on my Masterpage, and launching it via

    function LaunchAttachments() {  
      var parent = GetRadWindow().BrowserWindow;  
      var attach = parent.radopen("Attachments.aspx""rwAttachmentsMaster");  
      setTimeout(function() { attach.setActive(true); }, 100);  

    And this seems to now always bring the new window to the front.
  6. Jack Liao
    Jack Liao avatar
    10 posts
    Member since:
    Aug 2009

    Posted 24 Sep 2009 Link to this post

    Hi ,
    I also encountered this problem but in my case have some different.
    I pre-defined windows in windowmanager as below
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"  Skin="Vista"   
            Behavior="Default" InitialBehavior="None" Left=""   
            style="display: none;z-index: 7001" Top="" DestroyOnClose="True"   
            ShowContentDuringLoad="False" > 
            <Windows> 
            <telerik:RadWindow   
                ID="RadWinItemDetail"   
                ShowContentDuringLoad="false"   
                VisibleStatusbar="false"   
                VisibleTitlebar="false" 
                RestrictionZoneID="RestrictionZone"   
                Width="985px" Height="1250px" Behaviors="None" 
                style="z-index: 7000" 
                runat="server" OffsetElementId = "RestrictionZone" 
                DestroyOnClose="True">  
            </telerik:RadWindow> 
            <telerik:RadWindow   
                ID="winSearchWithin"   
                runat="server"   
                Width="800px" 
                Height="600px" 
                OffsetElementId = "pvItemDetail"   
                Behavior="Close" 
                onclientclose="GetPickupAddress" 
                NavigateUrl="" Modal="True"  DestroyOnClose="True" 
                VisibleTitlebar="True" ReloadOnShow="True">  
            </telerik:RadWindow> 
            <telerik:RadWindow   
                ID="winSearch"   
                runat="server"   
                Width="800px" 
                Height="600px"   
                Behavior="Close" 
                onclientclose="OnSearchWindowClose" 
                NavigateUrl="" Modal="True"  DestroyOnClose="True" 
                VisibleTitlebar="True" ReloadOnShow="True">  
            </telerik:RadWindow> 
            <telerik:RadWindow   
                ID="winContactor"   
                runat="server"   
                Width="600px" 
                Height="350px"   
                Behavior="Close"    
                NavigateUrl="" Modal="True" DestroyOnClose="True"   
                VisibleTitlebar="True" ReloadOnShow="True">  
            </telerik:RadWindow> 
            <telerik:RadWindow   
                ID="winPromptWindow"   
                runat="server"   
                Width="600px" 
                Height="350px"   
                Behavior="Close"    
                NavigateUrl="" Modal="True" DestroyOnClose="True"   
                VisibleTitlebar="True" ReloadOnShow="True">  
            </telerik:RadWindow> 
            </Windows> 
        </telerik:RadWindowManager> 
    I align the RadWinItemDetail window on RadMultiPage and open another window within RadWinItemDetail like underneath code snippets. due to I have a few pageview on the main page, I need to open it and set it be hidden first.
     
    var oWin = radopen("ItemDetail.aspx", "RadWinItemDetail");  
            oWin.setUrl('ItemDetail.aspx');  
            oWin.ShowContentDuringLoad = false;  
            oWin.set_width('980px');  
            oWin.argument = oArg;  
            oWin.hide(); 

    and then open another window within RadWinItemDetail , I would like the window 'winSearchWithin' always in the front. therefore, I set the winSearchWithin window's property Modal="True"  ,here is the code snippets:
    function openSubWinForSearchPickup(oArg) {  
                //        var targetPage="simpleSearch.aspx" 
                switch (oArg.strType) {  
                    case "PICKUP":  
                        var targetPage = "pkaddressSearch.aspx"; break;  
                    default:  
                        return false;  
                }  
                //        random seed to avoid page cashe.  
                var rendomPara = Math.round(Math.random() * 10000000000000000)  
                targetPage += "?actionnumb=" + rendomPara  
                switch (oArg.strType) {  
                    case "PICKUP":  
                        targetPage += "&CustCode="  
                        targetPage += encodeURIComponent(oArg.strSearchCode);  
                        break;  
                    default:  
                }  
                // use the current RadWindow to get a reference to the parent page, and use it to call radopen:  
                var oBrowserWnd = GetRadWindow().BrowserWindow;  
                var oWin = oBrowserWnd.radopen(targetPage, "winSearchWithin");  
                //need to use setTimeout function to bring the new window to the front.  
                setTimeout(function() {  
                    oWin.set_modal(true);  
                    oWin.set_width('800px');  
                    oWin.set_height('600px');  
                    oWin.center();  
                    oWin.argument = oArg;  
                    oWin.setActive(true);  
                }, 1000);  
            } 

    It does working in the first time opening , I have no idea how to fix it. Please help, thanks in advance.

    here is the working screen (only first time!)
    http://www.hecny.com.tw/datadl/2.jpg

    here is the malfunctioned screeen.
    http://www.hecny.com.tw/datadl/3.jpg

  7. Jack Liao
    Jack Liao avatar
    10 posts
    Member since:
    Aug 2009

    Posted 24 Sep 2009 Link to this post

    Hi,
    I fixed these problem in my project. sorry to bother you.
    I found that within window need to set_behaviors in client side instead of pre-define in WindowManager.
    oWin.set_behaviors(4); 
    and if also need to set the onclientclose method in contentwindow to return some thing.
    oWindow.add_close(yourMethodName); 


Back to Top