天天看點

關于在extjs中使用column布局,不能顯示textfield的标簽(fieldLabel)解決方法

  原因:fieldLabel is not rendered by the field itself, but by FormLayout. So for you to have a label you need to put the field in a form layout, e.g.

在coluumn的子項中加上layout:'form'就ok了   錯誤示例:

var d = new Ext.Window({ 
        title: instance, 
        layout: 'border', 
        width:375, 
        height:275, 
        cls: 'x-dialog-popup-main', 
        items: [{ 
            region: 'center', 
            title: 'General Information', 
            layout: 'table', 
            layoutConfig: { columns: 2 }, 
            items: [ 
                new Ext.form.TextField({ 
                    colspan: 2, 
                    fieldLabel: 'My Label', 
                    disabled: true, 
                    hideLabel: false 
                }) 
            ] 
        }, { 
            region: 'south', 
            title: 'Controls', 
            height: 100 
        }] 
    });  

           

需改動的:

layout: 'table',
layoutConfig: {columns: 2},
items: [{
  layout: 'form',
  colspan: 2, 
  items: [{
    xtype: 'textfield'
    fieldLabel: 'My Label', 
    disabled: true,
  }]
}]