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

Window Position?

8 Answers 233 Views
Window
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 07 Apr 2009, 06:01 PM
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

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2009, 10:59 AM
Hi Stephan,

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

Thanks
Shinu.
0
Stephen
Top achievements
Rank 1
answered on 08 Apr 2009, 03:20 PM
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.
0
Princy
Top achievements
Rank 2
answered on 09 Apr 2009, 11:07 AM
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.
0
Fiko
Telerik team
answered on 10 Apr 2009, 06:42 AM
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.
0
Stephen
Top achievements
Rank 1
answered on 11 Apr 2009, 06:16 AM
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?

0
Fiko
Telerik team
answered on 13 Apr 2009, 10:39 AM
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.
0
Stephen
Top achievements
Rank 1
answered on 13 Apr 2009, 04:38 PM
Thanks, this was very helpful.  I do have one question about this solution... Why was a setTimeout required?
0
Fiko
Telerik team
answered on 14 Apr 2009, 10:30 AM
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.
Tags
Window
Asked by
Stephen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Stephen
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Fiko
Telerik team
Share this question
or