国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS小練習代碼之二第1/2頁

2019-11-21 01:36:03
字體:
來源:轉載
供稿:網友
相關的源代碼如下:
1.beginFormPanel.js(作用:外層html文件中表單的展現)
<script>
var beginFormPanel = Ext.extend(Ext.form.FormPanel,{
constructor:function()
{
beginFormPanel.superclass.constructor.call
(
this,
{
title:"myForm(絕不裸奔)",
width:418,
height:180,
frame:true,
labelWidth:45,
style:"margin-left:250px",
defaultType:"textfield",
defaults:{anchor:"95%"},
items:
[
{
fieldLabel:"姓名",
name:"name"
},
{
fieldLabel:"年齡",
name:"age"
},
{
fieldLabel:"性別",
name:"sex"
},
{
fieldLabel:"住址",
name:"addr"
}
],
buttons:
[
{
text:"添加"
},
{
text:"修改"
},
{
text:"刪除"
}
],
renderTo:Ext.getBody()
}
) ;
}
}) ;
</script>
2.beginPanel.js(作用:GridPanel與窗口以及窗口中FormPanel的實現)
<script>
/**************************** FormPanel *****************************************************/
var myWindowForm = Ext.extend(Ext.form.FormPanel,{
constructor:function()
{
myWindowForm.superclass.constructor.call
(
this,
{
labelWidth:45,
defaultType:"textfield",
defaults:{anchor:"93%"},
style:"padding:5px",
baseCls:"x-plain",
items:
[
{
fieldLabel:"姓名",
name:"name",
allowBlank:false,
blankText:"姓名不能夠為空!"
},
{
fieldLabel:"年齡",
name:"age",
allowBlank:false,
vtype:"age",
blankText:"年齡不能夠為空!"
},
{
fieldLabel:"性別",
name:"sex",
allowBlank:false,
blankText:"性別不能夠為空!"
},
{
fieldLabel:"住址",
name:"addr",
allowBlank:false,
blankText:"住址不能夠為空!"
}
]
}
) ;
},
getValues:function()
{
if(this.getForm().isValid())
{
return new Ext.data.Record(this.getForm().getValues()) ;
}
else
{
throw error("表單驗證沒通過哦!") ;
}
},
setValues:function(record)
{
this.getForm().loadRecord(record) ;
},
reset:function()
{
this.getForm().reset() ;
}
}) ;
/******************************** Window ***********************************/
var myWindow = Ext.extend(Ext.Window,{
form:new myWindowForm(),
constructor:function()
{
myWindow.superclass.constructor.call
(
this,
{
title:"myWindow(絕不裸奔)",
width:300,
height:185,
frame:true,
plain:true,
modal:true,
items:this.form,
closable:false,//禁止關閉
collapsible:true,//可折疊
buttons:
[
{
text:"確定",
handler:this.onSubmitClick,
scope:this
},
{
text:"取消",
handler:this.onCancelClick,
scope:this
}
]
}
) ;
this.addEvents("submit") ;
},
close:function()
{
this.hide() ;
},
onSubmitClick:function()
{
/*
try
{
this.fireEvent("submit",this,this.form.getValues()) ;
}
catch (error)
{
Ext.Msg.alert("警告","請將需要填寫的信息填寫完整!") ;
}
*/
this.fireEvent("submit",this,this.form.getValues()) ;
this.close() ;
},
onCancelClick:function()
{
//上面不加scope屬性則提示this.form為空
this.form.reset() ;
this.close() ;
}
}) ;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿尔山市| 株洲县| 屏东县| 府谷县| 泰州市| 五寨县| 阜宁县| 任丘市| 南丰县| 太白县| 敦化市| 波密县| 华亭县| 科技| 辉南县| 将乐县| 芦溪县| 扬州市| 巧家县| 紫金县| 宜阳县| 昌都县| 巴彦淖尔市| 临安市| 华宁县| 武功县| 南投县| 林口县| 高青县| 措勤县| 织金县| 铜鼓县| 南部县| 宁夏| 乳源| 深水埗区| 曲靖市| 板桥市| 板桥市| 公主岭市| 鹤山市|