Tad
Tad

Reputation: 129

ExtJS4 simple textfield and label position

I have simple textfield but with larger height then normal:

enter image description here

definition is:

{
    xtype:      'textfield',
    itemId:     'POL_OGIN',
    fieldLabel: 'Login:',
    allowBlank: false,
    height:     60,
    name:       login',
 },

and I have no idea how to position label text "Login:", just center it vertically. Could you suggest how to do it?

Upvotes: 1

Views: 731

Answers (1)

Tejas
Tejas

Reputation: 902

Refer below fiddle: https://fiddle.sencha.com/#fiddle/2941&view/editor

As there was no cls/any other config readily available to change fieldLabel,so i added afterrender listener for field & changed fieldLabel's top.Also there is other approach as add cls to fieldLabel and assign margin-top there.Below is code:

listeners: {
            afterrender: function (field) {
                var height=field.getHeight()/2-10;//10 for label height
                field.labelCell.dom.querySelector('label').style['margin-top'] = height.toString()+'px';

                //-----OR----
                //Added class below
                //field.labelEl.addCls('loginTextFieldCls');
                //In cls give margin-top
            }
        }

Check if it helps you or not.

Upvotes: 1

Related Questions