gpt4 book ai didi

extjs - 表单提交后关闭extjs窗口

转载 作者:行者123 更新时间:2023-12-04 14:49:24 26 4
gpt4 key购买 nike

我有一个 extjs2 表单面板:

   var fsf = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
frame:true,
id: 'formPanel',
title: 'Simple Form with FieldSets',
bodyStyle:'padding:5px 5px 0',
width: 550,

items: [{
xtype:'fieldset',
checkboxToggle:true,
title: 'User Information',
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
collapsed: true,
items :[{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}
]
},{
xtype:'fieldset',
title: 'Phone Number',
collapsible: true,
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
items :[{
fieldLabel: 'Home',
name: 'home',
value: '(888) 555-1212'
},{
fieldLabel: 'Business',
name: 'business'
},{
fieldLabel: 'Mobile',
name: 'mobile'
},{
fieldLabel: 'Fax',
name: 'fax'
}
]
}],

buttons: [{
text: 'Save',
handler: function(){
var form = Ext.getCmp('formPanel').getForm();
if(form.isValid())
form.submit({
waitMsg:'Loading...',
url: 'RepeatSession.jsp',
success: function(form,action) {
//we have to close the window here!!
},
failure: function(form,action){
Ext.MessageBox.alert('Erro',action.result.data.msg);
}
});
}
},{
text: 'Cancel'
}]
});

和一个窗口:
 win = new Ext.Window(
{
layout: 'fit',
width: 500,
height: 300,
modal: true,
closeAction: 'hide',
items: fsf
});
win.show();

如您所见,表单面板作为项目位于窗口内。成功提交表单后,我必须关闭窗口,但我不知道如何访问成功处理程序中的窗口对象。

成功提交表单后如何隐藏窗口?

最佳答案

在创建表单之前,只需保存对窗口或其子窗口之一的引用。例如,您可以使用 handler 的按钮参数。函数通过:

        handler: function(button, e){

[...]
                    success: function(form,action) {
button.up('.window').close();
},

或者,由于您显然已经在变量( win )中拥有窗口,您可以使用它来关闭窗口:
win.close();

但这取决于变量 win在成功函数中可用,我们无法从您提供的代码中假设。

关于extjs - 表单提交后关闭extjs窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9456331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com