Там может быть более простой способ.В ExtJS 4 (я не тестировал в 3, но это может работать) при использовании макета vbox , если дочерний элемент имеет flex
из 0
или undefined
, менеджер компоновки не будет корректироватьсявысота этого элемента.
Так, для вашего примера, верхняя панель будет иметь flex
1
, а нижняя панель будет иметь flex
0
:
Ext.create("widget.panel", {
renderTo: Ext.getBody(),
height: 300, width: 400,
layout: { type: 'vbox', pack: 'start', align: 'stretch' },
items: [{
// our top panel
xtype: 'container',
flex: 1, // take remaining available vert space
layout: 'fit',
autoScroll: true,
items: [{
xtype: 'component',
// some long html to demonstrate scrolling
html: '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>'
}]
},{
// our bottom panel
xtype: 'container',
flex: 0, // dont change height of component (i.e. let children dictate size.)
items: [{
xtype: 'button',
height: 200,
text: 'Hello World'
}]
}]
});
Теперь нижняя панель будет принимать только высоту дочерних компонентов, а верхняя панель - оставшуюся доступную высоту.