Ext.window关闭

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

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

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

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

代码:

[java] view plaincopy
  1. //关闭按钮  
  2. this.ButtonClose =new Ext.Button({    
  3.     text:'关闭',  
  4.     id:'ButtonClose',  
  5.     width:200  
  6. });  
  7.   
  8. //新增按钮  
  9. this.ButtonNewAdd =new Ext.Button({   
  10.     text:'新增走访记录',  
  11.     id:'ButtonNewAdd',  
  12.     width:200  
  13. });  
  14.   
  15.   
  16. //******必须把new  window的操作放在这个 show方法里面  否则执行close操作后第二次就无法打开*****  
  17. this.win = new Ext.Window({  
  18.     id:'checkInfoWin',  
  19.     layout:'fit',  
  20.     width:800,  
  21.     height:500,  
  22.     modal : true,  
  23.     draggable : true,  
  24.     resizable : false,  
  25.     closeAction: 'close'//close 关闭  hide  隐藏  
  26.     animEl:'btnadd',  
  27.     title:"查看客户客走访信息",  
  28.       
  29.     buttons : [this.ButtonNewAdd, this.ButtonClose],  
  30.     items : this.showTabPanel  
  31.     
  32. });  
  33.   
  34.   
  35.   
  36. this.show = function(id,name){  
  37.     this.win.show();  
  38. }  
  39.   
  40. this.closeWin = function(){  
  41.     this.parentForm.store.reload();  
  42.     this.win.close();  
  43. }  


[java] view plaincopy
  1. <pre name="code" class="java">        
  2. <pre></pre>  
  3. <p>修改后的:</p>  
  4. <pre name="code" class="java">this.show = function(id,name){  
  5.           
  6.         //关闭按钮  
  7.         this.ButtonClose =new Ext.Button({    
  8.             text:'关闭',  
  9.             id:'ButtonClose',  
  10.             width:200  
  11.         });  
  12.           
  13.         //新增按钮  
  14.         this.ButtonNewAdd =new Ext.Button({   
  15.             text:'新增走访记录',  
  16.             id:'ButtonNewAdd',  
  17.             width:200  
  18.         });  
  19.           
  20.           
  21.           
  22.         this.win = new Ext.Window({  
  23.             id:'checkInfoWin',  
  24.             layout:'fit',  
  25.                 width:800,  
  26.             height:500,  
  27.             modal : true,  
  28.             draggable : true,  
  29.             resizable : false,  
  30.                <span style="color:#FF6666;"> closeAction: 'close'//close 关闭  hide  隐藏</span>  
  31.                 animEl:'btnadd',  
  32.                 title:"查看客户客走访信息",  
  33.               
  34.             buttons : [this.ButtonNewAdd, this.ButtonClose],  
  35.             items : this.showTabPanel  
  36.             
  37.         });  
  38.           
  39.         this.win.show();  
  40.     }  
  41.   
  42.     this.closeWin = function(){  
  43.         this.parentForm.store.reload();  
  44.         <span style="color:#FF6666;">this.win.close();</span>  
  45.     }  
  46. </pre><br>  
  47. 这样修改后 就可以正常的打开了。<img alt="大笑" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif">  
  48. <p><br>  
  49. </p>  
  50. <p><span style="font-size:16px">ps:注意红色部分的代码,及每段代码的位置.</span></p>  
  51. <p>本人认为出现此种情况的原因:改前  各组件对象只实例化了一次,window关闭后再打开时无法调到该组件,导致window无法显示</p>  
  52. <p>而将组件放到show方法里面后,每次调用show方法时组件都会被实例化一次,因此能能够正常显示。<br>  
  53. </p>  
  54. <br>  
  55. <p><br>  
  56. </p><table border="1" cellpadding="1" cellspacing="1" height="63" width="870">  
  57. <tbody>  
  58. <tr>  
  59. <td> </td>  
  60. <td> </td>  
  61. </tr>  
  62. <tr>  
  63. <td> </td>  
  64. <td> </td>  
  65. </tr>  
  66. <tr>  
  67. <td> </td>  
  68. <td> </td>  
  69. </tr>  
  70. </tbody>  
  71. </table>  
  72. <br>  
  73. <p></p>  
  74. <pre></pre>  
  75. <pre></pre>  
  76. <pre></pre>  
  77.       
  78.         <div style="padding-top:20px">           
  79.             <p style="font-size:12px;">版权声明:本文为博主原创文章,未经博主允许不得转载。</p>  
  80.         </div>  
  81. </pre>  

二、多层iframe嵌套页面中关才最外层的Ext Window

var windowElement = parent.Ext.fly(window.frameElement).up('div.x-window');

parent.Ext.getCmp(windowElement.id).close();



function closewindow() {
	var currentWin = window;
	while (top != currentWin) {
		var prentExt = currentWin.parent.Ext;
		var fElement = prentExt.get(currentWin.frameElement);
		var windowElement = fElement.up('div.x-window');
		if (windowElement) {
			var winId = windowElement.id;
			var extWin = prentExt.getCmp(winId);
			extWin.close();
			return true;
		} else {
			currentWin = currentWin.parent;
		}
	}
	alert('窗口关闭错误');
	return false;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值