Window Position?

9 posts, 0 answers
  1. Stephen
    Stephen avatar
    70 posts
    Member since:
    Mar 2008

    Posted 07 Apr 2009 Link to this post

    This might be a little off topic, but would anyone know how to position a window (retrieved from the WindowManager) relative to the top viewable area?  


    Thanks,
    Stephen
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Apr 2009 Link to this post

    Hi Stephan,

    Go through the following help document link which explains how you can show and position window.
    Showing and Positioning

    Thanks
    Shinu.
  3. Stephen
    Stephen avatar
    70 posts
    Member since:
    Mar 2008

    Posted 08 Apr 2009 Link to this post

    Thanks Shinu, but unfortunately this only answers part of my question.  The other part of my question is does someone know how to get the top position of the viewable area of the browser?  I want the title bar of the window to always be showing in the browser even if the user has scrolled down.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Apr 2009 Link to this post

    Hello Stephen,

    You can reposition the RadWindow using moveTo() method of RadWindow client side object. Try out the follwoing code.

    [ASPX]
     
    <input type="button" id="test1"  value="Scroll"  onclick="ScrollView();" />   
    <div id="test" style="position:absolute;visibility:hidden; background-color:black; color: white"></div>  

    [JavaScript]
     
    <script type="text/javascript">  
    var doit;  
    var oWnd;  
    function ScrollView()  
    {  
        var title = "Title";  
        var link = "Window.aspx";  
        oWnd = radopen(link,null);  
        oWnd.set_title(title);  
        oWnd.add_close(OnClientClose);  
        if (document.all||document.getElementById)  
        {  
            doit=setInterval("Scroll()",100)  
        }  
    }  
    function Scroll()  
    {  
        var object=document.all?document.all.test:document.getElementById('test');  
        var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;  
        var left=document.all? iebody.scrollLeft : pageXOffset;  
        var top=document.all? iebody.scrollTop : pageYOffset;  
        if(document.all || document.getElementById)  
        {  
        object.style.left=parseInt(100+left)+"px";  
        object.style.top=parseInt(100+top)+"px";  
        object.style.visibility="visible";  
        oWnd.moveTo(object.style.left,object.style.top);  
        }  
    }  
    function OnClientClose(sender, eventArgs)  
    {  
        clearInterval(doit);  
    }  
    </script> 

    Thanks,
    Princy.
  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 10 Apr 2009 Link to this post

    Hello Stephen,

    I believe that the following Code Library article will be of help:
    http://www.telerik.com/community/code-library/aspnet-ajax/window/floating-r-a-d-window-on-page-scroll-window-stays-visible-during-scrolling.aspx

    Sincerely yours,
    Fiko
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Stephen
    Stephen avatar
    70 posts
    Member since:
    Mar 2008

    Posted 11 Apr 2009 Link to this post

    function OpenWindow(name, url)  
    {  
        var manager = GetRadWindowManager();  
        var oWindow = manager.GetWindowByName(name);  
          
        oWindow.SetUrl(url);  
          
        oWindow.MoveTo(GetVisibleTop() + 20, 30);  
          
        oWindow.Show();  
    }  
     
    function GetVisibleTop()  
    {  
        var top = 0;  
          
        var appVersion = navigator.appVersion;  
        if (appVersion.indexOf('MSIE') > 1)  
        {  
            if (document.compatMode=="CSS1Compat")  
            {  
                top = document.documentElement.scrollTop;  
            }  
            else 
            {  
                top = document.body.scrollTop;  
            }  
        }  
        else 
        {  
            top = window.pageYOffset;  
        }  
          
        return top;  

    How would I get this working if I called OpenWindow from an OnClientClick of a asp:ImageButton?

  7. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 13 Apr 2009 Link to this post

    Hi Stephen,

    For your convenience I reworked the FloatWindow_Web_UI project from this Code Library page and attached it to this thread. You could use it as a base in your project.

    I hope this helps.

    Sincerely yours,
    Fiko
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  8. Stephen
    Stephen avatar
    70 posts
    Member since:
    Mar 2008

    Posted 13 Apr 2009 Link to this post

    Thanks, this was very helpful.  I do have one question about this solution... Why was a setTimeout required?
  9. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 Apr 2009 Link to this post

    Hi Stephen,

    Yes you are right, in the last provided floatwindow-web-ui.zip example you do not need to use the following part of the code:

    function InitWindow() 
        setTimeout(function() 
        { 
            var oWindow = stickyRadWindow;  // GetRadWindowManager().getActiveWindow(); 
            if (oWindow) // This is the right
            { 
                window.setTimeout(InitWindow, 500); 
            } 
            PositionWindow(); 
        }, 0); 

    because I disable the movable capability of the RadWindow - by using the following code :
    stickyRadWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.None); 

    In case that the RadWindow object is movable, and the client move it, you need to reset the position of the RadWindow. This is the main idea of using the InitWindow() function.

    I hope this answers your question.

    Greetings,
    Fiko
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top