最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to put two Ext.Panels to the left and right of each other in another Ext.Panel? - Stack Overflow

programmeradmin2浏览0评论

I'm trying to create a layout in ExtJS which has a grid on top and on the bottom left and right sections, a basic parent/child, master/details layout:

wrapper_panel
panel_top
  [grid]
panel_bottom
  [left_area     right_area]

However, the two areas in panel_bottom are on top of each other instead of to the left and right

var left_area = new Ext.Panel({
    region: 'west',
    layout: 'fit',
    width: 100,
    items: []
});

var right_area = new Ext.Panel({
    region: 'center',
    layout: 'fit',
    width: 100,
    items: []
});


var panel_bottom = new Ext.Panel({
    //layout: 'border',
    region: 'south',
    items: [ left_area, right_area ]
})

It looks like this:

If I make the panel_bottom layout: border then the left and right areas disappear pletely.

What do I need to change in the bottom area panels so that they line up left and right?

Addendum

@vimvds, if I add width: 200 or e.g. width: 300, I just get this:

Thanks for the answers, it led me to scrap this and use the table layout instead, which led me to another question how to define percentage instead of absolute values for height/width.

I'm trying to create a layout in ExtJS which has a grid on top and on the bottom left and right sections, a basic parent/child, master/details layout:

wrapper_panel
panel_top
  [grid]
panel_bottom
  [left_area     right_area]

However, the two areas in panel_bottom are on top of each other instead of to the left and right

var left_area = new Ext.Panel({
    region: 'west',
    layout: 'fit',
    width: 100,
    items: []
});

var right_area = new Ext.Panel({
    region: 'center',
    layout: 'fit',
    width: 100,
    items: []
});


var panel_bottom = new Ext.Panel({
    //layout: 'border',
    region: 'south',
    items: [ left_area, right_area ]
})

It looks like this:

If I make the panel_bottom layout: border then the left and right areas disappear pletely.

What do I need to change in the bottom area panels so that they line up left and right?

Addendum

@vimvds, if I add width: 200 or e.g. width: 300, I just get this:

Thanks for the answers, it led me to scrap this and use the table layout instead, which led me to another question how to define percentage instead of absolute values for height/width.

Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Feb 11, 2011 at 9:47 Edward TanguayEdward Tanguay 194k321 gold badges725 silver badges1.1k bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I'd use a Ext.layout.HBoxLayout:

var panel_bottom = new Ext.Panel({
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    defaults: {
        flex: 1
    },
    items: [ left_area, right_area ],
});

Alternatively you could also use a Ext.layout.TableLayout or a Ext.layout.ColumnLayout:

var panel_bottom = new Ext.Panel({
    layout: 'column',
    defaults: {
        columnWidth: 0.5
    },
    items: [ left_area, right_area ],
});

And what happens if you use :

var panel_bottom = new Ext.Panel({
    layout: 'border',
    items: [ left_area, right_area ],
    width: 200
});
发布评论

评论列表(0)

  1. 暂无评论