2014-05-19 61 views
5

我使用ExtJS版本4.2.1,並且我有一個表格佈局。如何根據其容器調整ExtJS文本字段寬度

 Ext.create('Ext.panel.Panel', { 
      width: 1300, 
      height: 700, 
      title: 'Table Layout', 
      layout: { 
       type: 'table', 
       columns: 3, 
       tdAttrs: 
        { 
         width: 500, 
        } 
      }, 
      items: [ 
       { 
        fieldLabel: 'Text1', 
        xtype: 'textfield', 
       }, 
       { 
        fieldLabel: 'Text2', 
        xtype: 'textfield', 
       }, 
       { 
        fieldLabel: 'Text3', 
        xtype: 'textfield', 
       }, 
       { 
        fieldLabel: 'Text4', 
        xtype: 'textfield', 
       }, 
       { 
        fieldLabel: 'Text5', 
        xtype: 'textfield', 
       }, 
       { 
        fieldLabel: 'Text6', 
        xtype: 'textfield', 
       }], 
      renderTo: Ext.getBody() 
     }); 

,其結果是: enter image description here 每個列的寬度是500像素,我想每個文本框的寬度及其容器進行調整。不知何故一個autoWidth,但它現在不。以百分比

回答

5

添加寬度與文本框:

Ext.create('Ext.panel.Panel', { 
    width: 1300, 
    height: 700, 
    title: 'Table Layout', 
    layout: { 
     type: 'table', 
     columns: 3, 
     tdAttrs: { 
      width: 500, 
     } 
    }, 
    defaults: { 
     width: '95%' 
    }, 
    items: [ 
     // ... 
    ], 
    renderTo: Ext.getBody() 
}); 
相關問題