还有一种 通过ajax请求一个js的方式 实现新增一个tab页
这里给出一个小例子
[code="java"] if(!tabs.getItem(id)){
Ext.Ajax.request({
url:"<%=path%>/js/"+url,//这里是的请求那个js的具体地址 url稍微改一下
success: function(response, opts){
var obj = eval(response.responseText);
obj.id=id,
tabs.add(obj);
tabs.setActiveTab(obj);
tabs.doLayout();
},
failure : function(response, options) {
Ext.Msg.alert("系统信息", "请求失败");
}
});
}else{
tabs.setActiveTab(tabs.getItem(node.id));
}[/code]
然后给出所请求的简单的一个js代码(代码简单 只是一个例子而已)
code="java"{
AccountUi = Ext.extend(Ext.form.FormPanel, {
title: 'Account',
labelWidth: 100,
labelAlign: 'left',
layout: 'form',
width: 600,
frame: true,
initComponent: function() {
this.items = [
{
xtype: 'container',
autoEl: 'div',
layout: 'column',
items: [
{
xtype: 'container',
autoEl: 'div',
layout: 'form',
columnWidth: 0.5,
items: [
{
xtype: 'textfield',
fieldLabel: 'First Name',
anchor: '95%',
name: 'fname',
ref: '../../fname'
},
{
xtype: 'datefield',
fieldLabel: 'Birth of day',
anchor: '95%',
name: 'birthday',
ref: '../../birthday'
}
]
},
{
xtype: 'container',
autoEl: 'div',
layout: 'form',
columnWidth: 0.5,
items: [
{
xtype: 'textfield',
fieldLabel: 'Last Name',
anchor: '95%',
name: 'lname',
ref: '../../lname'
},
{
xtype: 'combo',
fieldLabel: 'Sex',
anchor: '95%',
name: 'sex',
ref: '../../sex'
}
]
}
]
},
{
xtype: 'htmleditor',
anchor: '98%',
fieldLabel: 'Memo',
height: 150,
width: 300,
name: 'memo',
ref: 'memo'
}
];
this.fbar = {
xtype: 'toolbar',
items: [
{
xtype: 'button',
text: 'Save',
ref: '../saveBtn'
},
{
xtype: 'button',
text: 'Reset',
ref: '../resetBtn'
}
]
};
AccountUi.superclass.initComponent.call(this);
}
});
Account = Ext.extend(AccountUi, {
initComponent: function() {
Account.superclass.initComponent.call(this);
this.saveBtn.on('click', this.doSaveAction, this);
},
doSaveAction: function() {
alert(this.fname.getValue());
}
});
var account = new Account();
return new Ext.Panel({ //这个js返回的东西
draggable: false,
closable:true,
items:[account],
});
})() //匿名函数
[/code]