我喜欢将MessageBox标签分开。一个MessageBox将显示在一个特定的选项卡中,并将从所有其他选项卡中隐藏。现在显示为全球性的应用。有没有办法在应用程序的每个选项卡下显示消息?
当messagebox是单例时,你不能同时在不同的选项卡上使用具有不同内容的消息框,但是你可以创建自己的消息框,从Window扩展并将每个实例呈现到单独的选项卡上。这里有一个本地窗口的例子,但它对扩展组件的工作原理是一样的。
您不能直接使用Ext.window.MessageBox
来实现您想要的。另一方面,您可以创建一个扩展Ext.window.Window
的小实用程序类,使用静态函数使其以标题、消息和按钮作为参数显示,并使用constrainTo
选项使其属于您的选项卡。
这样,你就有了一个可以被选项卡"拥有"的窗口,而不是全局出现
这里我创建了一个函数来显示消息为消息框。我可以随时使用它。
ShowPrivateMessage: function(title, widthValue, heightValue, msgText, renderTabId){
Ext.create("Ext.window.Window",{
title : title,
width : widthValue,
height: heightValue,
html : '<span style="font-size: small">'+ msgText + '</span>',
renderTo: renderTabId,
resizable: false,
draggable: false,
bodyPadding: '10px',
listeners:{
afterrender: function(sender, eOpt){
var parentWindow = Ext.getCmp(renderTabId);
parentWindow.disable();
}
,close: {
fn:function(ctrl,opt){
var parentWindow = Ext.getCmp(renderTabId);
parentWindow.enable();
}
}
}
}).show();
}