2014-05-19 63 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() 
}); 
相关问题