Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: alignTo problem

  1. #1
    Sencha User
    Join Date
    Oct 2009
    Posts
    27

    Question alignTo problem

    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.

    Code:
    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();
                    }
          }]
    });

  2. #2

    Default

    Try using this.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.

    Code:
    myWin.show();
    myWin.alignTo(Ext.get('novaAutButton'));
    Project manager / coder @ xDesk ERP

  3. #3
    Sencha User
    Join Date
    Oct 2009
    Posts
    27

    Default

    No, this.alignTo didn't work... Firebug says 'p is undefined'

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

  4. #4

    Default

    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.
    Project manager / coder @ xDesk ERP

  5. #5

    Default

    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:

    Code:
    this.alignTo(Ext.get('novaAutButton'), 'bl');
    Project manager / coder @ xDesk ERP

  6. #6
    Sencha User
    Join Date
    Oct 2009
    Posts
    27

    Default

    API says that it is optional...

    Example Usage:
    Code:
    // align el to other-el using the default positioning ("tl-bl", non-constrained)
    
    el.alignTo("other-el");
    But, It works now!
    Code:
    this.alignTo( Ext.get('novaAutButton'), 'bl' );
    Thanks!

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Quote Originally Posted by dvuja2 View Post
    API says that it is optional...
    Careful. Read the correct API. The one you were helpfully shown:


  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Element alignTo docs don't say that it's optional either.


  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    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.

  10. #10
    Sencha User
    Join Date
    Oct 2009
    Posts
    27

    Default

    position : StringThe position to align to (see 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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •