PDA

View Full Version : Resize vBox/hBox childs.



defnull
1 Dec 2010, 4:50 AM
Hi there. I have a simple vBox layout with two panels in it:



+------------------+
| height: 20 (top) |
+------------------+
| flex: 1 (bottom) |
+------------------+I would like to resize the 'top' panel and let the vBox layout handle the size of the 'bottom' panel automatically. It figured out how to do this, but it seems quite inconvenient. I'd like to ask if there is a better way.



/* Setup code */
var topPanel = new Ext.Panel({height: 20, html:'top'})
var bottomPanel = new Ext.Panel({flex: 1, html:'bottom'})
var vboxPanel = new Ext.Window({layout: 'vbox',
layoutConfig: {
align : 'stretch'
},
width: 300, height:400,
items: [topPanel, bottomPanel]})
vboxPanel.show()

/* Resize code */
topPanel.setHeight(40)
topPanel.height = 40 // see below
vboxPanel.syncSize()I know that 'topPanel.height' is not a public property, but it is required by 'Ext.layout.VBoxLayout.calculateChildBoxes()' and not updated by 'topPanel.setHeight(40)'. I have to adjust it manually to get this to work. Any suggestions?