当前位置: 编程技术>jquery
Extjs4实例:Form之submit和load的用法
来源: 互联网 发布时间:2014-09-03
本文导语: 本节内容: Extjs4 Form之submit和load 例子: 代码示例: Ext.onReady(function(){ Ext.QuickTips.init(); Ext.create("Ext.form.Panel",{ title:'本地load实例', renderTo:'formDemo', bodyPadding:'5 5 5 5',...
本节内容:
Extjs4 Form之submit和load
例子:
代码示例:
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.create("Ext.form.Panel",{
title:'本地load实例',
renderTo:'formDemo',
bodyPadding:'5 5 5 5',
height:300,
width:400,
frame:true,
defaults:{
labelSeparator :": ",
labelWidth : 70,
width : 300,
allowBlank: false,
msgTarget : 'side',
labelAlign:'left'
},
items:[{
fieldLabel:'ID',
xtype:'textfield',
name:'userId',
value:'001'//硬编码写值
},{ // www.
fieldLabel:'NAME',
xtype:'textfield',
name:'userName',
value:'uspcat.com'//硬编码写值
},{
fieldLabel:'AGE',
xtype:'numberfield',
name:'userAge',
value:'1'//硬编码写值
},{
xtype:'textareafield',
width:300,
height:150,
name:'info',
fieldLabel:'INFO'
}],
buttons:[{
text:'提交数据',
handler:function(){
//得到form
var basic = this.up("form").getForm();
basic.submit({
clientValidation: true,//要经过客户端验证的
params:{userName:'sss'},//可以传参数过去
url: '/extjs/extjs!getFormValues.action',
method:'POST',
success:function(){
Ext.Msg.alert('提示',"提交数据");
}
});
}
},{
text:'加载远程数据',
handler:function(){
//得到form
var basic = this.up("form").getForm();
//得到userId
var userId = basic.findField("userId").getValue();
basic.load({ // www.
params:{userId:userId},
url:'/extjs/extjs!getFormValues.action',
method:'POST',
success:function(form,action){
Ext.Msg.alert('提示',"加载成功");
},
failure:function(form,action){
Ext.Msg.alert('提示',"失败原因是: "+action.result.errorMessage);
}
});
}
}]
});
});
Ext.QuickTips.init();
Ext.create("Ext.form.Panel",{
title:'本地load实例',
renderTo:'formDemo',
bodyPadding:'5 5 5 5',
height:300,
width:400,
frame:true,
defaults:{
labelSeparator :": ",
labelWidth : 70,
width : 300,
allowBlank: false,
msgTarget : 'side',
labelAlign:'left'
},
items:[{
fieldLabel:'ID',
xtype:'textfield',
name:'userId',
value:'001'//硬编码写值
},{ // www.
fieldLabel:'NAME',
xtype:'textfield',
name:'userName',
value:'uspcat.com'//硬编码写值
},{
fieldLabel:'AGE',
xtype:'numberfield',
name:'userAge',
value:'1'//硬编码写值
},{
xtype:'textareafield',
width:300,
height:150,
name:'info',
fieldLabel:'INFO'
}],
buttons:[{
text:'提交数据',
handler:function(){
//得到form
var basic = this.up("form").getForm();
basic.submit({
clientValidation: true,//要经过客户端验证的
params:{userName:'sss'},//可以传参数过去
url: '/extjs/extjs!getFormValues.action',
method:'POST',
success:function(){
Ext.Msg.alert('提示',"提交数据");
}
});
}
},{
text:'加载远程数据',
handler:function(){
//得到form
var basic = this.up("form").getForm();
//得到userId
var userId = basic.findField("userId").getValue();
basic.load({ // www.
params:{userId:userId},
url:'/extjs/extjs!getFormValues.action',
method:'POST',
success:function(form,action){
Ext.Msg.alert('提示',"加载成功");
},
failure:function(form,action){
Ext.Msg.alert('提示',"失败原因是: "+action.result.errorMessage);
}
});
}
}]
});
});