2011-02-11 106 views
3

在下面的代码,如果我定义顶部区域作为对象常量,那么它会覆盖细默认表宽度:如何使Ext.Panel宽度覆盖其父表布局的宽度?

var top_area = { 
    title:'Orders', 
    width: 1210, 
    colspan: 4, 
    frame: true, 
    border: true, 
    header: true 
}; 

enter image description here

Howver,如果我将其定义为Ext.Panel,然后它错误发生在表中的缺省宽度:

var top_area = new Ext.Panel({ 
    title:'Orders', 
    width: 1210, 
    colspan: 4, 
    frame: true, 
    border: true, 
    header: true 
}); 

enter image description here

如何让Ext.Panel重写表的默认高度?

下面是完整的代码:

var top_area = new Ext.Panel({ 
    title:'Orders', 
    width: 1210, 
    colspan: 4, 
    frame: true, 
    border: true, 
    header: true 
}); 

var table_wrapper2 = new Ext.Panel({ 
    id: 'table_wrapper2', 
    baseCls: 'x-plain', 
    renderTo: Ext.getBody(), 
    layout:'table', 
    layoutConfig: {columns:2}, 
    defaults: { 
     frame:true, 
     width:300, 
     height: 300, 
     style: 'margin: 0 10px 10px 0' 
    }, 
    items:[{ 
      title:'Shopping Cart', 
      width: 600, 
      height: 390, 
      colspan: 2 
     }, 
     { 
      title:'Invoice Address', 
      width: 290, 
      height: 200 
     },{ 
      title:'Delivery Address', 
      width: 300, 
      height: 200 
     } 
    ] 
}) 

var table_wrapper = new Ext.Panel({ 
    id:'table_wrapper', 
    baseCls:'x-plain', 
    renderTo: Ext.getBody(), 
    layout:'table', 
    layoutConfig: {columns:4}, 
    defaults: { 
     frame:true, 
     width: 300, 
     height: 300, 
     style: 'margin: 10px 0 0 10px' 
    }, 
    items:[top_area,{ 
      title:'Customer Information', 
      width: 600, 
      height: 600, 
      colspan: 2 
     },{ 
      frame: false, 
      border: false, 
      width: 600, 
      height: 600, 
      colspan: 2, 
      items: [ table_wrapper2 ] 
     } 
    ] 
}); 
+2

Amol以下是正确的,这解决了您的问题。也许最好查看vbox和hbox布局,我喜欢那些比桌面布局好得多的东西,没有跨度和所需的东西。 – 2011-02-11 15:04:38

回答

4

尝试删除默认的宽度,因为要覆盖其所有项目的反正。

defaults: { 
    frame:true, 
    width: 300, //<-- remove this 
    height: 300, 
    style: 'margin: 10px 0 0 10px' 
},