var testBt = new Ext.Button({
text : "测试",
tooltip : 's',
iconCls : 'print',
handler : function() {
p = new com.resoft.test.Persons();
p.init("测试s");
p.showMessage();
p2 = new com.resoft.test.Persons();
p2.init({name:"测试JS OOP"});
p2.addListener({
"showMessageEvt" :function(value){
alert(">>>"+value);
},
"getNameEvt" :function(value){
alert("<<<"+value);
}
});
p2.showMessage();
for(o in p2)
p2[o]=null;
p2 = null;
p3 = new com.resoft.test.Persons();
p3.init({name:"测试JS OOP"});
//设置表单的值不会共享
var ay = p3.getQueryForm().find("name","test");
ay[0].setValue("dkfjk");
//s[0].setValue("KDFJKDf");
p3.showMessage();
p3 = null;
p3 = null;
}
})
Ext.namespace("com.resoft.test");
//根据输入的 id和 Text创建对象信息
com.resoft.test.CText = Ext.extend(Ext.util.Observable,{
id : '',
fieldLabel :'',
allowBlank: true,
init: function(config)
{
Ext.apply(this, config);
var xText = new Ext.form.TextField({
//id : this.name,
name : this.name,
fieldLabel :this.fieldLabel,
allowBlank : this.allowBlank,
maxLength : 100,
width : 150
});
return xText;
}
});
//表单定义
com.resoft.test.query = Ext.extend(Ext.util.Observable,{
nameQ : null,
passQ : null,
getNameQ:function(){
return this.nameQ;
},
getPassQ:function(){
return this.passQ;
},
init : function(){
this.nameQ = new com.resoft.test.CText().init({name:'test',fieldLabel:"名称1",allowBlank:true});
this.passQ = new com.resoft.test.CText().init({id:"q2",fieldLabel:"名称2",allowBlank:true});
},
getQueryPanel : function(){
this.init();
var fPanel = new Ext.FormPanel({
title:'测试',
autoHeight : true,
autoWidth : true,
collapsible : true,
autoScroll : true,
labelAlign : 'right',
border : true,
hideBorders : true,
labelWidth : 100,
layout : 'table',
layoutConfig : {
columns : 2
},
defaults : {
layout : 'form',
width : 280
},
items : [{
items :this.nameQ
},{
items :this.passQ
}]
});
return fPanel;
}
}
);
com.resoft.test.Persons = Ext.extend(Ext.util.Observable,{
queryForm: null,
getQueryForm :function()
{
//创建查询表单
return this.queryForm
},
init:function(config)
{
Ext.apply(this, config);
this.queryForm = new com.resoft.test.query().getQueryPanel();
this.addEvents({
"getNameEvt" : true,
"showMessageEvt" : true
});
},
getName:function()
{
this.fireEvent("getNameEvt",this.name);
},
showMessage:function()
{
var name1 = new com.resoft.test.CText().init({id:"1",fieldLabel:"名称1",allowBlank:true});
var name2 = new com.resoft.test.CText().init({id:"2",fieldLabel:"名称2",allowBlank:true});
var name3 = new com.resoft.test.CText().init({id:"3",fieldLabel:"名称3",allowBlank:false});
var name4 = new com.resoft.test.CText().init({id:"4",fieldLabel:"名称4",allowBlank:true});
var fPanel = new Ext.FormPanel({
// title:'档案附属信息',
autoHeight : true,
autoWidth : true,
collapsible : true,
autoScroll : true,
labelAlign : 'right',
border : true,
hideBorders : true,
labelWidth : 100,
layout : 'table',
layoutConfig : {
columns : 2
},
defaults : {
layout : 'form',
width : 280
},
items : [
{
items :name1
},{
items : name2
},
{
items: name3
},
{
items :name4
}
],
buttons:[
new Ext.Button({
text:"关闭",
handler:function(){
boxMyFormWin.destroy();
//queryForm.destroy();
// boxMyFormWin.destroy();
Ext.destroy(this.queryForm);
this.queryForm = null;
}
})]
});
var boxMyFormWin = new Ext.Window({
layout : 'fit',
width : 680,
bodyStyle : 'padding:5px;',
autoHeight : true,
buttonAlign : 'center',
closeAction : 'hide',
constrain : true,
maximizable : false,
plain : true,
autoScroll : true,
modal : true,
title : this.name,
items : [
this.queryForm, fPanel
]
});
boxMyFormWin.show();
this.fireEvent("showMessageEvt",this.name);
},
destory:function()
{
this.queryForm = null;
}
});
Ext OOP概念编程.
最新推荐文章于 2021-03-17 03:24:32 发布