PDA

View Full Version : alignTo problem



dvuja2
6 Nov 2009, 2:10 AM
Hello, I don't understand why this doesn't work, anybody? I'm trying to align the window to the bottom left of the button.

Currently it shows the window in the middle of the screen at the bottom.


myWin = new Ext.Window(
{
***,
listeners:
{
'beforeshow': function ()
{
this.el.alignTo( Ext.get('novaAutButton') );
}
}
});

myGrid = new Ext.grid.GridPanel(
{
***,
tbar: [
{
***,
id: 'novaAutButton',
handler: function ()
{
myWin.show();
}
}]
});

uniring
6 Nov 2009, 3:06 AM
Try using this.alignTo (http://www.extjs.com/deploy/dev/docs/?class=Ext.Window&member=alignTo) instead of this.el.alignTo.

Also try to align the window after you show it, i think you can be having problems with the beforeshow event not triggering.



myWin.show();
myWin.alignTo(Ext.get('novaAutButton'));

dvuja2
6 Nov 2009, 3:11 AM
No, this.alignTo (http://www.extjs.com/forum/../deploy/dev/docs/?class=Ext.Window&member=alignTo) didn't work... Firebug says 'p is undefined' :-/

And the event is triggering, I did an alert('!');

uniring
6 Nov 2009, 3:14 AM
Try then to align the window after it's shown, it can be that the window dimensions aren't calculated at the beforeshow event, i'm not sure but you can try.

uniring
6 Nov 2009, 3:18 AM
Oh, stop, you're using alignTo without the position, that's why you get a p is undefined error. Position is not optional, try to use:


this.alignTo(Ext.get('novaAutButton'), 'bl');

dvuja2
6 Nov 2009, 3:43 AM
API says that it is optional...

Example Usage:
// align el to other-el using the default positioning ("tl-bl", non-constrained)

el.alignTo("other-el");

But, It works now!

this.alignTo( Ext.get('novaAutButton'), 'bl' );

Thanks! :)

Animal
6 Nov 2009, 4:03 AM
API says that it is optional...

Careful. Read the correct API. The one you were helpfully shown:

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/alignToDocs.jpg

Animal
6 Nov 2009, 4:05 AM
Element alignTo docs don't say that it's optional either.

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/elementalignToDocs.jpg

Animal
6 Nov 2009, 4:10 AM
Though there have been some changes there recently, and the new code defaults it to "tl-bl?"

I'll add a note to both places to that effect.

dvuja2
6 Nov 2009, 4:27 AM
position : StringThe position to align to (see Ext.Element.alignTo (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.Element.html#Ext.Element-alignTo) for more details).When I follow the link it says:


The position parameter is optional, and can be specified in any one of the following formats:Blank: Defaults to aligning the element's top-left corner to the target's bottom-left corner ("tl-bl")...It's inconsistent but I should have seen that it's not optional in the API, so my apologies. :)

Animal
6 Nov 2009, 6:05 AM
When I follow the link it says:

It's inconsistent but I should have seen that it's not optional in the API, so my apologies. :)

There's recently been some fixing of the code in that area, so it could be that the defaulting was always supposed to be there, but just didn't work. The next release will default as that description says.