我有一个带有hbox布局的容器。我用一个按钮添加另一个带有按钮的容器,问题是内容永远不会进入第二行,只停留在第一行。主容器具有固定的宽度,并且位于窗口内。我怎样才能做到这一点?我希望它能像css中的'break-word'一样工作。谢谢你的帮助。
screenshoot:http://www.ohecollegeplanner.com/cp/img.png
getSelectedItemsCmp: function () {
var items = [];
var container = Ext.create("Ext.container.Container", {
layout: "hbox",
align: 'stretch',
id: "tagContainer",
height: 70,
//flex:2,![enter image description here][1]
overflowY: "auto",
width: "400px",
padding: 5
});
for (var i = 0; i < this.selectedItems.length; i++) {
var tag = this.createSelectedItemsTag(this.selectedItems[i]);
container.add(tag);
}
//container.doLayout();
return container;
},
createSelectedItemsTag: function (obj) {
var tag = {
xtype: "container",
id: "tag_" + obj.value,
cls: "tagCompContainer",
layout: {
type: "hbox"
},
items: [{
xtype: "label",
text: obj.label,
cls: "labelSelectedComps"
}, {
xtype: "button",
text: "x",
id: "tagbutton_" + obj.value,
listeners: {
click: {
fn: this.onDeleteSelectedCmpClick,
scope: this
}
}
}
]
};
return tag;
},
答案 0 :(得分:2)
你得到的正是hbox所做的......它水平地分配容器的物品。也许尝试使用表格布局?