ExtJS4:使用MVC模式正确设置waitMsgTarget
我有extjs 4.0控制器:ExtJS4:使用MVC模式正确设置waitMsgTarget,extjs4,extjs-mvc,Extjs4,Extjs Mvc,我有extjs 4.0控制器: form.getForm().waitMsgTarget = form.getEl(); form.getForm().waitMsg = 'Sending...'; Ext.define('KS.controller.dailReport'{ 扩展:“Ext.app.Controller”, 视图:['report.Daily'], init:function(){ 这是我的控制({ “DailReport按钮[action=send]”:{ 单击:this.
form.getForm().waitMsgTarget = form.getEl();
form.getForm().waitMsg = 'Sending...';
Ext.define('KS.controller.dailReport'{
扩展:“Ext.app.Controller”,
视图:['report.Daily'],
init:function(){
这是我的控制({
“DailReport按钮[action=send]”:{
单击:this.senddailreport
}
});
},
sendDailyReport:功能(按钮){
var win=按钮向上('窗口');
形式=赢下(“形式”);
form.getForm().waitMsgTarget=form.getEl();
form.getForm().waitMsg='Sending…';
如果(form.getForm().isValid()){//请确保表单在提交前包含有效数据
提交表格({
成功:功能(形式、行动){
Ext.Msg.alert('Success',action.result.Msg);
},
失败:功能(形式、动作){
Ext.Msg.alert('Failed',action.result.Msg);
}
});
}else{//如果数据无效,则显示错误警报
Ext.Msg.alert('无效数据','更正它们!')
}
}
});
和extjs视图:
Ext.define('KS.view.report.Daily'{
扩展:“Ext.window.window”,
别名:“widget.dailyReport”,
标题:"日报",,
布局:“适合”,
汽车展:是的,
initComponent:function(){
此项。项目=[{
waitMsgTarget:是的,
xtype:'表单',
url:'dailyReport.php',
布局:“适合”,
waitMsgTarget:是的,
waitMsg:'正在发送…',
项目:[{
差额:10,
xtype:'日期字段',
名称:“报告日期”,
fieldLabel:“报告对象:”,
格式:“d.m.Y.”,
备选格式:“d.m.Y | d,m,Y | m/d/Y”,
值:“2011年12月12日”,
禁用日期:[0]
}]
}];
此按钮=[{
文本:“发送”,
操作:“发送”
},
{
文本:“取消”,
范围:本,,
处理程序:这个。关闭
}];
this.callParent(参数);
}
});
正如您所见,我试图在这两个位置设置waitMsgTarget和waitMsg,但当我单击“发送”按钮时,它并没有出现
怎么了?您实际上只是在以下方面误用了
waitMsg
:
waitMsg
不是Ext.form.Basic
或Ext.form.Panel
的配置选项。必须在Ext.form.action.Submit
中设置waitMsg
。这就是为什么在视图中设置它永远不会起作用waitMsg
设置为Ext.form.Basic
的属性Ext.form.action.Submit中设置waitMsg
。因此,只需将form.submit()
中的行更改为如下内容:
form.submit({
waitMsg: 'Sending...',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
//..... your other stuff here
});
并从控制器上拆下以下线路:
form.getForm().waitMsgTarget = form.getEl();
form.getForm().waitMsg = 'Sending...';
为了完整起见,请从视图中删除这两行(您在其中有两次waitMsgTarget
):
注意:要将waitMsgTarget
定义为表单本身以外的内容,必须传入目标的id
例如,在视图(即表单定义)中,您希望将waitMsgTarget:true
更改为:
waitMsgTarget: 'myWindowID',
//where myWindowID is the id of the container you want to mask
有关参考,请参阅:
和
这解决了我最初的问题,但我仍然不知道如何阻止窗体的父窗口,而不是整个视口?我将waitMsgTarget:true移到表单定义之外,现在它会阻止整个视口。还有一个问题:我的提交和取消按钮在成功/失败时消失:(waitMsgTarget:true将屏蔽实际表单。您不需要移动放置它的位置,您需要将“true”更改为对父窗口的引用。请查看我为表单提供的链接。Basic,它将为您提供有效选项的说明。换句话说,waitMsgTarget不仅仅是一个布尔值,将其设置为true只是一个简单的设置。)屏蔽表单本身的方便方法。就您的按钮而言,请尝试在init函数之外设置它们。当我以您现在的方式进行操作时,会发生一些奇怪的事情。因此,只需将它们作为与autoShow等相同级别的配置选项放入即可。很抱歉这么麻烦您。将waitMsgTarget设置为父windo的合适方法是什么w、 将视图中的waitMsgTarget设置为该值将返回null,并且该.up('window')将阻塞整个视口。