Ext2中window中如果panel是缓存,在IE6中可能会遇到的问题

十一月 17, 2008 | 标签 extjs  panel   | 浏览
评论 0
EXT2中如果window不缓存,而其中的panel缓存,
在IE6中下次打开一个新的window,并把该panel加到新的window中时,该panel会显示不出来。
主要是因为window在被destory时会无条件的把其中的panel也destory。
解决方法是在window被close之前,把要缓存的panel放到另一个现有的panel中,测试代码如下:
testwindow.html代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
<link rel="stylesheet" type="text/css" href="../../../ext2.2.1/resources/css/ext-all.css" />
</head>
<script type="text/javascript" src="../../ext2.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext2.2.1/ext-all-debug.js"></script>
<script type="text/javascript" src="../../ext2.2.1/source/locale/ext-lang-zh_CN.js"></script>
<body>
<input type="button" value="test" onclick="testdomain.openFunc();"/>
<script type="text/javascript" src="testwindow.js"></script>
</body>
</html>


testwindow.js代码如下:
Ext.namespace("testdomain");
Ext.onReady(function(){
    testdomain.apanel=new Ext.Panel({
        title:'otherpanel',
        width:1000,
        layout:'fit',
        height:600,
        items:[{
            xtype:"textarea"
        }]
    });
    testdomain.apanel.render(document.body);
//    testdomain.apanel.hide();
    
    testdomain.testini=function(){
        testdomain.testpanel=new Ext.Panel({
            title:'cachedpanel',
            width:750,
            region: 'center',
            height:550,
            html:'afd',
            listeners:{
                 beforedestroy:function(th){
                    alertv("testpanel_beforedestroy");
                    return false;    
                }
            }
        });
    };
    
    var alertv=function(v){
        testdomain.apanel.items.get(0).setValue(v+"\n\n"+testdomain.win.getEl().dom.innerHTML+"\n"+"\n"+"\n"+testdomain.testpanel.getEl().dom.innerHTML+"\n\n"+testdomain.testpanel.rendered);
        alert(v);
    }
    
    testdomain.openFunc=function(){
        var firstd=false;
        if (typeof testdomain.testpanel=="undefined" || testdomain.testpanel==null) {
            testdomain.testini();
            firstd=true;
        }

    testdomain.win = new Ext.Window({
            layout:"fit",
            title:"windowtitle1",
            width:820,
            height:515,
            items:[testdomain.testpanel],
            listeners:{
                  beforeclose:function(th){
                    alertv("win_beforeclose");
                    th.remove(testdomain.testpanel,true);
                    testdomain.apanel.add(testdomain.testpanel);
                    testdomain.apanel.doLayout();
                    testdomain.apanel.remove(testdomain.testpanel,true);
                    alertv("win_beforeclose2");
                    return true;
                },
                 beforedestroy:function(th){
                    alertv("win_beforedestroy");
                    return true;
                },
                destroy:function(){
                    alertv("win_destroy");
                }
            }
        });
   testdomain.win.render(document.body);
        alertv("win.beforshow");
        testdomain.win.show();
    }    
    
});




发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。