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

getWindowBounds, setSize and moveTo

1 Answer 248 Views
Window
This is a migrated thread and some comments may be shown as answers.
neebs
Top achievements
Rank 2
neebs asked on 25 Jan 2010, 12:59 AM
I am using getWindowbounds to obtain the position of a RadWindow after a drag event, and saving that in a cookie. Then, if they close the RadWindow and later re-open it, I am using setSize and moveTo to reposition it. The code appears as follows:

                function WindowMoved(sender, args) { 
                    window.setTimeout(function() { 
                        SaveSizeAndPosition(sender, args); 
                    }, 10); 
                } 
                function SaveSizeAndPosition(sender, args) { 
                    var oWnd = $find("<%= RadWindowRealMcCoy.ClientID %>"); 
                    if (oWnd != undefined) { 
                        debugger
                        createCookie('RealMcCoyManagerWindowTop', oWnd.getWindowBounds().y, 365); 
                        createCookie('RealMcCoyManagerWindowLeft', oWnd.getWindowBounds().x, 365); 
                        createCookie('RealMcCoyManagerWindowHeight', oWnd.getWindowBounds().height, 365); 
                        createCookie('RealMcCoyManagerWindowWidth', oWnd.getWindowBounds().width, 365); 
                    } 
                } 
                function ShowDialog() { 
                    var oWnd = $find("<%= RadWindowRealMcCoy.ClientID %>"); 
                    if ((oWnd != null) && (oWnd != undefined)) { 
                        var x = readCookie('RealMcCoyManagerWindowLeft'); 
                        var y = readCookie('RealMcCoyManagerWindowTop'); 
                        var height = readCookie('RealMcCoyManagerWindowHeight'); 
                        var width = readCookie('RealMcCoyManagerWindowWidth'); 
                        if (x) { 
                            if (oWnd._firstShow == undefined) { 
                                oWnd.setSize(width, height); 
                                oWnd.moveTo(x, y); 
                            } 
                        } 
 
                        oWnd.show(); 
                    } 
                } 
 

It appears that the result of this is a window that is slightly offset from where it should be. See the two images below, the first is after moving the window, and the second is after re-opening it.



1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 25 Jan 2010, 02:39 PM
Hello neebs,

The code that you posted looks OK and is working as expected on my side. Just for testing purposes, try calling moveTo() with a small timeout and if this doesn't help, please open a support ticket and send a sample project that can be run locally and reproduces the problem. We will check it and do our best to help.


Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Window
Asked by
neebs
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
Share this question
or