Ext formPanel 按钮作用域问题

浅笑黄花伊人泪 2014-03-31 01:19:23
一个小程序,点击按钮重置表单,为什么提示:Cannot call method 'getForm' of undefined
是不是formBasic没有获得 该怎么解决
代码如下

layout:'form',
xtype:'fieldset',
title:'上午第一大节',
aotuHeight:true,
/*defaultType:'numberfield',*/
items:[
{layout:'column',//对每一个fieldset进行列排列
items:[
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM1end',
maxValue:20,
minValue:1
},{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start2',
maxValue:20,
minValue:1
},{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM2end2',
maxValue:20,
minValue:1
}]
}
]
},
{},{},{}]
,buttons: [
{
// 重设按钮
text: '重设',
// 单击该按钮时重设表单
handler: function()
{
this.up('form').getForm().reset();
/* Ext.Msg.alert("按钮","巴塞罗那球迷"); */
}
},
{
// 提交按钮
text: '提交',
formBind: true, // 只有当整个表单输入校验通过时,该按钮才可用
disabled: true, // 设置该按钮默认不可用
// 单击该按钮的事件处理函数
handler: function()
{
// 获取表单,实际返回的是Ext.form.Basic对象
var form = this.up('form').getForm();
// 如果表单输入校验通过
if (form.isValid())
{
// 以Ajax方式提交表单
form.submit(
{
// 提交成功,第一个参数是Ext.form.Basic对象
// 第二个参数是Ext.action.Action对象
success: function(form, action)
{
Ext.Msg.alert('提交成功!', action.result.msg);
},
// 提交失败
failure: function(form, action)
{
Ext.Msg.alert('提交失败!', action.result.msg);
}
});
}
}
}
]



...全文
63 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
上面漏贴了一部分

{
id: 'card-1',
layout:'form',
title:'周一课程录入',
url:'courseIn',
name:'form',
/* layout: 'hbox',*/
/*method:' Monday',*///传入后台可以每周建立一个方法判断录入
method:'POST',
renderTo: Ext.getBody(),
width:20,

bodyPadding: 1,
items: /*[
//上午第一大节课录入
{
filedLabel:'上午第一大节',
title: '上午第一大节',
layout: 'hbox',
bodyPadding: 5,
height: 80, // 指定高度
items: [
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM1end',
maxValue:20,
minValue:1
},
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start2',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM2end2',
maxValue:20,
minValue:1
}
],
flex: 4,
resizable: {
handles: 'n s ns',
minWidth: 200,
minHeight: 80,
maxWidth: 500,
maxHeight: 400,
transparent:false,
pinned: true
}
},
// 上午第二大节课录入
{

title: '上午第二大节',
layout: 'hbox',
bodyPadding: 5,
height: 80, // 指定高度
items: [
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM2start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM2end',
maxValue:20,
minValue:1
},
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM2start2',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM2end2',
maxValue:20,
minValue:1
}
],
flex: 4,
resizable: {
handles: 'n s ns',
minWidth: 200,
minHeight: 80,
maxWidth: 500,
maxHeight: 400,
transparent:false,
pinned: true
}
},
//下午第一大节课
{

title: '下午第一大节',
layout: 'hbox',
bodyPadding: 5,
height: 80, // 指定高度
items: [
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'PM1start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'PM1end',
maxValue:20,
minValue:1
},
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'PM1start2',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'PM1end2',
maxValue:20,
minValue:1
}
],
flex: 4,
resizable: {
handles: 'n s ns',
minWidth: 200,
minHeight: 80,
maxWidth: 500,
maxHeight: 400,
transparent:false,
pinned: true
}
},
//下午第二大节课录入
{

title: '下午第二大节',
layout: 'hbox',
bodyPadding: 5,
height: 80, // 指定高度
items: [
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'PM2start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'PM2end',
maxValue:20,
minValue:1
},
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'PM2start2',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'PM2end2',
maxValue:20,
minValue:1
}
],
flex: 4,
resizable: {
handles: 'n s ns',
minWidth: 200,
minHeight: 80,
maxWidth: 500,
maxHeight: 400,
transparent:false,
pinned: true
}
}




]*/
[
{
layout:'form',
xtype:'fieldset',
title:'上午第一大节',
aotuHeight:true,
/*defaultType:'numberfield',*/
items:[
{layout:'column',//对每一个fieldset进行列排列
items:[
{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start',
maxValue:20,
minValue:1
},
{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM1end',
maxValue:20,
minValue:1
},{
fieldLabel: '起始周',
xtype: 'numberfield',
name:'AM1start2',
maxValue:20,
minValue:1
},{
fieldLabel: '结束周',
xtype: 'numberfield',
name:'AM2end2',
maxValue:20,
minValue:1
}]
}
]
},
{},{},{}]
,buttons: [
{
// 重设按钮
text: '重设',
// 单击该按钮时重设表单
handler: function()
{
this.up('form').getForm().reset();
/* Ext.Msg.alert("按钮","巴塞罗那球迷"); */
}
},
{
// 提交按钮
text: '提交',
formBind: true, // 只有当整个表单输入校验通过时,该按钮才可用
disabled: true, // 设置该按钮默认不可用
// 单击该按钮的事件处理函数
handler: function()
{
// 获取表单,实际返回的是Ext.form.Basic对象
var form = this.up('form').getForm();
// 如果表单输入校验通过
if (form.isValid())
{
// 以Ajax方式提交表单
form.submit(
{
// 提交成功,第一个参数是Ext.form.Basic对象
// 第二个参数是Ext.action.Action对象
success: function(form, action)
{
Ext.Msg.alert('提交成功!', action.result.msg);
},
// 提交失败
failure: function(form, action)
{
Ext.Msg.alert('提交失败!', action.result.msg);
}
});
}
}
}
]


}

这是完整的 效果图如下:

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧