日期:2014-05-16  浏览次数:20315 次

ExtJS让被遮盖的窗体显示在最前面以及解决Ext.MessageBox提示框被TabPanel覆盖的方法
一、如何让ExtJS的弹出提示信息框Ext.MessageBox或者创建的Ext.Window显示在最前面:

下面是显示一个Window的JS代码:

var formPanel = MisTab1.createAddFormPanel();
var addWin = new Ext.Window({  
    title: "添加产品类别", 
    pageX: 50,
    pageY: 50,
    width: 600,  
    height: 200,  
    plain: true, 
    resizable: false,  	    
    collapsible: true,   
    closeAction: 'close',  
    closable: true,
    modal: 'true',  
    buttonAlign: "center",
    bodyStyle: "padding:20px 0 0 0",
    alwaysOnTop: true,
    items: [formPanel],  
    buttons: [{  
           text: "添 加",  
           minWidth: 70,  
           handler: function() {                
           }  
       }, {  
           text: "关 闭",  
           minWidth: 70,  
           handler: function() { 
           }  
       }]    
});	
addWin.show();

效果如图:

想要让Window显示在最前面,只要创建一个WindowGroup管理创建的Window即可,需要添加的代码如下:

var tab1GroupMgr = new Ext.WindowGroup();  
//前置窗口
tab1GroupMgr.zseed=99999;  

var addWin = new Ext.Window({  
    title: "添加产品类别", 
    pageX: 50,
    pageY: 50,
    width: 600,  
    height: 200,  
    plain: true,
    manager: tab1GroupMgr,
...

二、ExtJS弹出提示信息框Ext.MessageBox或者创建的Ext.Window被Ext.TabPanel覆盖的解决方法

出现这种原因可能是因为TabPanel设置了floating:true配置项。

floating : Boolean
True表示为浮动此面板(带有自动填充和投影的绝对定位),false...
True表示为浮动此面板(带有自动填充和投影的绝对定位),false表示为在其渲染的位置"就近"显示(默认为false)。True to float this Panel (absolute position it with automatic shimming and shadow), false to display it inline where it is rendered (defaults to false).

解决方法就是把设置的floationg:true配置项去掉:

var tabPanel = new Ext.TabPanel({
	region: 'center',
	activeTab:0,
	shadow: true,
	floating: true,    //去掉该配置项
	items: [{
		title: '欢迎页面'
	}]
});
除了文章中有特别说明,均为IT宅原创文章,转载请以链接形式注明出处。
本文链接:http://www.itzhai.com/extjs-form-to-be-displayed-on-the-front-cover-and-solve-ext-messagebox-boxes-are-covered-by-the-method-tabpanel.html
关键字: ExtJS, floating, TabPanel, 遮盖