如何使Ext.Panel宽度覆盖其父表布局的宽度?

时间:2011-02-11 12:05:33

标签: javascript extjs

在下面的代码中,如果我将顶部区域定义为 object literal ,那么它会覆盖默认的表格宽度:

var top_area = {
    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
});

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 ]
        }
    ]
});

1 个答案:

答案 0 :(得分:4)

尝试删除默认宽度,因为无论如何都要覆盖所有项目。

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