有关EXT重复打开window的问题

ijse 2011-02-06 09:45:53
写了一个window类,当closeAction设为close时,第一次打开正常,再打开就提示Can not read Property 'autoCreate' of undefined..
当closeAction设为hide时,第一次打开正常,再打开不提示错误,但页面显示 不正常了,内容不显示。

下面是代码:

UserEditWindowUi = Ext.extend(Ext.Window, {
title: '创建一位管理账户 ',
width: 341,
height: 412,
layout: 'fit',
resizable: false,
modal: true,
closeAction: 'hide',
initComponent: function() {
this.items = [
{
xtype: 'form',
height: 359,
padding: 10,
formId: 'UserEditForm',
items: [
{
xtype: 'fieldset',
title: '填写用户信息',
width: 305,
height: 293,
items: [
{
xtype: 'textfield',
fieldLabel: '登陆名称',
anchor: '100%',
name: 'tuser.loginName',
allowBlank: false,
blankText: '登陆名称不能为空!',
maxLength: 20,
minLength: 5,
minLengthText: '最小长度为5个字符!',
ref: '../../loginName'
},
{
xtype: 'textfield',
fieldLabel: '密码',
anchor: '100%',
name: 'tuser.passWord',
inputType: 'password',
allowBlank: false,
blankText: '密码不能为空!',
maxLength: 20,
ref: '../../passWord'
},
{
xtype: 'textfield',
fieldLabel: '密码确认',
anchor: '100%',
name: 'tuser.passWord2',
inputType: 'password',
blankText: '密码确认不能为空!',
maxLength: 20,
ref: '../../passWord2'
},
{
xtype: 'textfield',
fieldLabel: '真实姓名',
anchor: '100%',
maxLength: 20,
name: 'tuser.userName',
ref: '../../userName'
},
{
xtype: 'combo',
fieldLabel: '指定用户组',
anchor: '100%',
name: 'tuser.groupName',
store: 'UserGroupStore',
displayField: 'name',
triggerAction: 'all',
allowBlank: false,
resizable: true,
submitValue: true,
disableKeyFilter: true,
editable: false,
blankText: '必须指定一个用户组!',
valueField: 'id',
ref: '../../groupName'
},
{
xtype: 'checkbox',
fieldLabel: '是否锁定',
boxLabel: '锁定,暂不启用',
anchor: '100%',
ref: '../../t_islocked'
},
{
xtype: 'textarea',
anchor: '100%',
fieldLabel: '备注说明',
name: 'tuser.about',
maxLength: 255,
ref: '../../about'
},
{
xtype: 'hidden',
fieldLabel: 'Label',
anchor: '100%',
name: 'tuser.id',
ref: '../../tuserId'
},
{
xtype: 'hidden',
fieldLabel: 'Label',
anchor: '100%',
name: 'tuser.locked',
ref: '../../islocked'
}
]
},
{
xtype: 'container',
width: 309,
height: 48,
layout: 'absolute',
items: [
{
xtype: 'button',
text: '提交保存',
x: 60,
y: -1,
width: 70,
height: 40,
type: 'submit',
ref: '../../btn_Save'
},
{
xtype: 'button',
text: '清除重填',
x: 180,
y: 0,
width: 70,
height: 40,
type: 'reset',
ref: '../../btn_Reset'
}
]
}
]
}
];
UserEditWindowUi.superclass.initComponent.call(this);
}
});

我是用Ext Designer生成的,上面是UserEditWindow.ui.js,下面UserEditWindow.js里我加入了一些自己的代码:

UserEditWindow = Ext.extend(UserEditWindowUi, {
initComponent : function() {
UserEditWindow.superclass.initComponent.call(this);
this.btn_Save.on("click", function() {
var progbar = Ext.MessageBox.wait("",
"正在向服务器发送信息...");
var thisWnd = this;

// 判别是编辑还是添加
var requestUrl = "System/User_regist.do";
var successInfo = "用户添加成功!";
if (Number(this.tuserId.getValue()) != 0) {
requestUrl = "System/User_edit.do";
successInfo = "用户信息修改成功!";
} else {
this.tuserId.setValue(0);
}

// 验证表单数据,通过后才能提交数据
if (!this.find("formId", "UserEditForm")[0]
.getForm().isValid()) {
Ext.MessageBox.alert("提示",
"表单数据验证失败,请修改后重新提交 !");
return;
}

// 确定提交所有数据
this.loginName.setDisabled(false);
this.passWord2.setDisabled(false);
this.islocked.setValue(this.t_islocked.getValue());

Ext.Ajax.request({
url : requestUrl,
form : "UserEditForm",
success : function(response, e) {
try {
var obj = Ext
.decode(response.responseText);
if (obj.result.success == true) {
progbar.hide();
Ext.MessageBox.alert("提示",
successInfo);
thisWnd.close();
} else {
progbar.hide();
Ext.MessageBox
.alert(
"错误",
obj.result.errormsg);
}
} catch (e) {
progbar.hide();
Ext.MessageBox.alert("错误",
"您没有相应的权限!",
function() {
new LoginWindow()
.show();
});
}
},
failure : function() {
progbar.hide();
Ext.MessageBox.alert("错误",
"服务器未响应请求,请检查服务器是否正常运行!");
}
});
}, this);
}
});




我是这样子测试的,用new Ext.Window().show();, 显示几个都没问题,但是显示我自己写的就有问题了。
function fn() {
new UserEditWindowUi().show();
}
<a onclick="fn()">window 1 </a>
<a onclick="fn()">window 2 </a>



谢谢解答!
...全文
277 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ijse 2012-03-11
  • 打赏
  • 举报
回复
谢谢你~!
[Quote=引用 3 楼 shenxinfeng 的回复:]

只要把"formId: 'UserEditForm',"注释掉就行啦。。
[/Quote]
  • 打赏
  • 举报
回复
只要把"formId: 'UserEditForm',"注释掉就行啦。。
  • 打赏
  • 举报
回复
把“formId: 'UserEditForm',”这个注释掉就可以啦。。
ijse 2011-02-06
  • 打赏
  • 举报
回复
哦,,对了,可以把指定store的那个属性去掉的,否则 没这个store会出问题。。

25,985

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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