//点击树节点,中间的tabpanel新建一个对应的tab
west_chem.on('itemclick',function(view,record,item,index,e){
var cen_tabs = Ext.getCmp("cen_tabPanel");
if(record.raw.leaf){
e.stopEvent();
var addnew = cen_tabs.getComponent(record.raw.id);
var id = record.raw.id;
if(!addnew){
addnew = cen_tabs.add({
itemId : record.raw.id,
title: record.raw.text,
autoScroll:true,
closable:true,
closeAction:'close',
items:[inorg_all_grid], //每个panel加载的grid不同,要怎么做?
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
items: [ '->', {
xtype: 'textfield',
fieldLabel:'查询条件',
name: 'searchBy'
}, {
xtype: 'button',
text: '搜索'
},{
xtype: 'button',
text: '增加',
}
}]
}]
}).show();
}
cen_tabs.setActiveTab(addnew);
}
});
------解决方案--------------------
将itemclick处理封装到一个方法中:如:
var cen_tabs = Ext.getCmp("cen_tabPanel");