PDA

View Full Version : Window position relative to top and right



Chau
9 Feb 2010, 2:20 AM
Hi!

I would like to position my Ext.Window a few pixels from the top right corner of my application. I have looked at the x, y, setPosition(), but they all uses the top/left as reference. In my case, stylesheets are not an option unless a style (not a class) can be applied directly when creating the window.

I have looked at the style property, but I haven't been able to locate a list of valid styles yet.

Do you have any good advices for doing this?

cplist
15 Feb 2010, 9:32 AM
I'm not sure if this is the best approach, but I got the job done by asking the main viewport what its width was and making the window's x the viewport's width - window's width.

win.x = viewport.getBox().width - win.width;
win.y = 0;

Chau
22 Feb 2010, 12:18 AM
@cplist: Yeah I thought about that approach too, but haven't tried it yet. I was just hoping for a neat solution where I could use the right side of the window as reference instead of the left side. I'll probably end up using your solution, so thanks a lot for your answer ;)

Animal
22 Feb 2010, 12:26 AM
myWin.alignTo(Ext.getBody(), "tr-tr", [-10, 10]);


http://www.extjs.com/deploy/dev/docs/?class=Ext.Window&member=alignTo

Chau
22 Feb 2010, 2:16 AM
myWin.alignTo(Ext.getBody(), "tr-tr", [-10, 10]);
http://www.extjs.com/deploy/dev/docs/?class=Ext.Window&member=alignTo

Hi Animal. Thanks for again pointing me to one of the methods in the huge amount of possibilities in the documentation :">

It works great. One thing though: In your example you use Ext.getBody(), which works fine. But if I use Ext.getCmp('...') it fails in the getAlignToXY in the line el = Ext.get(el); which returns null.

Why is it that I have to use Ext.get('...') instead?

Animal
22 Feb 2010, 2:53 AM
They are different methods.

They do different things.

Things which the documentation tells you.

Chau
22 Feb 2010, 3:00 AM
They are different methods.

They do different things.

Things which the documentation tells you.
I had a look at the code behind the Ext.get(...), which seems to respond differently according to the argument it recieves. But still it cannot handle the component I give it. This was actually why I asked you. The differences between the two methods, I can lookup my self - as you suggest me to do and most other Extjs users. A bit harsh answer you give us maybe, but I think its fine - let us do the work our selves ;)

Thanks for your answers - they helped a lot!

Animal
22 Feb 2010, 3:02 AM
There's no point in spending hundreds of man hours writing docs only to then use my time acting as a conduit for the API documentation. Look it up for you and post it!