如果EXTJS 中toolbar中控件太多,不换行显示的话,整个界面就会出现标题栏和下面数据显示部分宽度不一的情况。
在EXTJS 3.0版本中开始有buttongroup组件,可以实现换行了。
但是在3.0以前的版本中要实现换行其实也比较简单,方法如下:
//先定义几个Toolbar:
var oneTbar=new Ext.Toolbar({
items:[
{text:'复制'}, {text:'粘贴'} ]
});
var twoTbar=new Ext.Toolbar({
items:[
{text:'编辑}, {text:'删除'} ]
});
//在grid中增加listeners ::
var grid = new Ext.grid.GridPanel({
id:'button-grid',
store: store,
cm: cm,
...........
tbar:[{text:'查询'}, {text:'搜索'} ]
listeners : {
'render' : function(){
oneTbar.render(this.tbar); //add one tbar
twoTbar.render(this.tbar); //add two tbar
}},
renderTo:document.getElementById("Mygrid")
});