关于Ext.window的隐藏(hide)和销毁(close)的问题

在这两天的开发中我碰到这样一个问题,在第一次打开window时数据正常,但是第二次及以后打开时现实的额数据任然是第一次打开的数据。

经查找发现此时window调用的关闭方式是hide而不是close,即每次关闭时实质上是没有关闭的只是把window隐藏了而已,此时只要把关闭方法用close即可,而且把closeAction:'close'这样配置即可。

但是此时问题又发生了,此时window打开一次后就无法打开了

代码:

	//关闭按钮
	this.ButtonClose =new Ext.Button({	
		text:'关闭',
		id:'ButtonClose',
		width:200
	});
	
	//新增按钮
	this.ButtonNewAdd =new Ext.Button({	
		text:'新增走访记录',
		id:'ButtonNewAdd',
		width:200
	});
	
	
	//******必须把new  window的操作放在这个 show方法里面  否则执行close操作后第二次就无法打开*****
	this.win = new Ext.Window({
		id:'checkInfoWin',
		layout:'fit',
		width:800,
		height:500,
		modal : true,
		draggable : true,
		resizable : false,
		closeAction: 'close', //close 关闭  hide  隐藏
		animEl:'btnadd',
		title:"查看客户客走访信息",
		
		buttons : [this.ButtonNewAdd, this.ButtonClose],
		items : this.showTabPanel
	  
	});

	
	
	this.show = function(id,name){
		this.win.show();
	}
	
	this.closeWin = function(){
		this.parentForm.store.reload();
		this.win.close();
	}


		

修改后的:

this.show = function(id,name){
		
		//关闭按钮
		this.ButtonClose =new Ext.Button({	
			text:'关闭',
			id:'ButtonClose',
			width:200
		});
		
		//新增按钮
		this.ButtonNewAdd =new Ext.Button({	
			text:'新增走访记录',
			id:'ButtonNewAdd',
			width:200
		});
		
		
		
		this.win = new Ext.Window({
			id:'checkInfoWin',
		   	layout:'fit',
		        width:800,
		   	height:500,
		   	modal : true,
		   	draggable : true,
		   	resizable : false,
		        closeAction: 'close', //close 关闭  hide  隐藏
		        animEl:'btnadd',
		        title:"查看客户客走访信息",
	        
	      	buttons : [this.ButtonNewAdd, this.ButtonClose],
	       	items : this.showTabPanel
		  
		});
		
		this.win.show();
	}

    this.closeWin = function(){
        this.parentForm.store.reload();
        this.win.close();
    }

这样修改后 就可以正常的打开了。大笑


ps:注意红色部分的代码,及每段代码的位置.

本人认为出现此种情况的原因:改前  各组件对象只实例化了一次,window关闭后再打开时无法调到该组件,导致window无法显示

而将组件放到show方法里面后,每次调用show方法时组件都会被实例化一次,因此能能够正常显示。



  
  
  




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值