Results 1 to 7 of 7

Thread: how to align text on a textfield to the right???

  1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    45

    Default how to align text on a textfield to the right???

    hello everyone i was just wondering how to align the text of a textfield to the right so that it would look like this:

    sample.jpg

    this is the code i used:
    Code:
    xtype      : 'textfield', // 4
    fieldLabel : 'Amount Due',
    name       : 'amt_due',    
     style: 'text-align: right'
    it works in extjs3 but why does it not work in extjs4?? can anyone help please?..
    i'll wait for your answers..thank you...

  2. #2

    Default

    afterRender or onRender event :
    Code:
    me.inputEl.setStyle('text-align', 'right');

  3. #3
    Sencha User kiranadn.net's Avatar
    Join Date
    Jun 2011
    Location
    Calicut,India
    Posts
    48

    Default

    Hi,


    As per my observation,you can specify labelAlign : 'right' in the textfield configs.


    Regards,
    Kiran

  4. #4

    Default

    Code:
    me.inputEl.setStyle('text-align', 'right');
    This style is text align in textbox. labelAlign : 'right' in the textfield config for label align style.

  5. #5

    Default

    Quote Originally Posted by kiranadn.net View Post
    Hi,


    As per my observation,you can specify labelAlign : 'right' in the textfield configs.


    Regards,
    Kiran
    No, you cant. labelAlign aligns the label associated with a textfield, not the text within the textfield.

    Quote Originally Posted by muratyildiz View Post
    afterRender or onRender event :
    Code:
    me.inputEl.setStyle('text-align', 'right');
    This.
    No one stands taller than the last man standing

  6. #6
    Ext JS Premium Member
    Join Date
    Sep 2009
    Location
    Arlington, VA
    Posts
    33

    Default

    Since this thread hit first in my Google search I thought I would add that setting the fieldStyle parameter also worked for me. So something like:

    Code:
    {
        xtype: 'textfield',
        fieldLabel: 'My label',
        fieldStyle: 'text-align: right;'
    }

  7. #7

    Default

    it's worked for me too.
    thanks

Posting Permissions

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