ExtJS4 简单文本域和标签位置

ExtJS4 simple textfield and label position

我有简单的文本字段,但高度比正常的大:

定义为:

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

而且我不知道如何放置标签文本 "Login:",只需将其垂直居中即可。你能建议怎么做吗?

参考下面fiddle: https://fiddle.sencha.com/#fiddle/2941&view/editor

由于没有 cls/any 其他配置可用于更改 fieldLabel,因此我为字段添加了 afterrender 侦听器并更改了 fieldLabel top.Also 还有其他方法,如将 cls 添加到 fieldLabel 并分配边距-顶部 there.Below 是代码:

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
            }
        }

看看对你有没有帮助。