如何告诉extjs4只展开hbox
布局中的一个元素?
例如,我有以下布局:
{
flex: 1,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
flex: 1,
// GRID, needs to be stretched
}, {
// button, don't stretch
}, {
// another button, don't stretch
}]
}
在上面的代码中,我已经拉伸了所有元素(包括按钮)。是否可以在盒子布局中使用?
我当然可以在hbox容器中包装按钮,但我不喜欢这个解决方案。
答案 0 :(得分:1)
您可以使用的一种解决方法是给按钮maxHeight
,因为约束总是“赢”。
Ext.onReady(function(){
Ext.create('Ext.panel.Panel', {
width: 400,
height: 300,
renderTo: document.body,
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
flex: 1,
title: 'A panel'
}, {
xtype: 'button',
text: 'B1',
maxHeight: 25
}, {
xtype: 'button',
text: 'B2',
maxHeight: 25
}]
})
});