❶ 求解Extjs问题: 通过树节点,打开一个页面添加到tabpanel,关闭之后,再次打开不显示页面怎么解决
Ext.getCmp("centerPanel").remove(e);
你都remove掉了怎么可能还show回来,show对应的应该是hide
❷ extjs5中tabpanel鼠标右键全部关闭如何实现
给你例子参考,关联到右键就可以了
/**
* Plugin for adding a close context menu to tabs. Note that the menu respects
* the closable configuration on the tab. As such, commands like remove others
* and remove all will not remove items that are not closable.
*/
Ext.define('Ext.ux.TabCloseMenu', {
alias: 'plugin.tabclosemenu',
mixins: {
observable: 'Ext.util.Observable'
},
/**
* @cfg {String} closeTabText
* The text for closing the current tab.
*/
closeTabText: 'Close Tab',
/**
* @cfg {Boolean} showCloseOthers
* Indicates whether to show the 'Close Others' option.
*/
showCloseOthers: true,
/**
* @cfg {String} closeOthersTabsText
* The text for closing all tabs except the current one.
*/
closeOthersTabsText: 'Close Other Tabs',
/**
* @cfg {Boolean} showCloseAll
* Indicates whether to show the 'Close All' option.
*/
showCloseAll: true,
/**
* @cfg {String} closeAllTabsText
* The text for closing all tabs.
*/
closeAllTabsText: 'Close All Tabs',
/**
* @cfg {Array} extraItemsHead
* An array of additional context menu items to add to the front of the context menu.
*/
extraItemsHead: null,
/**
* @cfg {Array} extraItemsTail
* An array of additional context menu items to add to the end of the context menu.
*/
extraItemsTail: null,
// TODO - doc this.addEvents('aftermenu','beforemenu');
//public
constructor: function (config) {
this.mixins.observable.constructor.call(this, config);
},
init : function(tabpanel){
this.tabPanel = tabpanel;
this.tabBar = tabpanel.down("tabbar");
this.mon(this.tabPanel, {
scope: this,
afterlayout: this.onAfterLayout,
single: true
});
},
onAfterLayout: function() {
this.mon(this.tabBar.el, {
scope: this,
contextmenu: this.onContextMenu,
delegate: '.x-tab'
});
},
onBeforeDestroy : function(){
Ext.destroy(this.menu);
this.callParent(arguments);
},
// private
onContextMenu : function(event, target){
var me = this,
menu = me.createMenu(),
disableAll = true,
disableOthers = true,
tab = me.tabBar.getChildByElement(target),
index = me.tabBar.items.indexOf(tab);
me.item = me.tabPanel.getComponent(index);
menu.child('#close').setDisabled(!me.item.closable);
if (me.showCloseAll || me.showCloseOthers) {
me.tabPanel.items.each(function(item) {
if (item.closable) {
disableAll = false;
if (item != me.item) {
disableOthers = false;
return false;
}
}
return true;
});
if (me.showCloseAll) {
menu.child('#closeAll').setDisabled(disableAll);
}
if (me.showCloseOthers) {
menu.child('#closeOthers').setDisabled(disableOthers);
}
}
event.preventDefault();
me.fireEvent('beforemenu', menu, me.item, me);
menu.showAt(event.getXY());
},
createMenu : function() {
var me = this;
if (!me.menu) {
var items = [{
itemId: 'close',
text: me.closeTabText,
scope: me,
handler: me.onClose
}];
if (me.showCloseAll || me.showCloseOthers) {
items.push('-');
}
if (me.showCloseOthers) {
items.push({
itemId: 'closeOthers',
text: me.closeOthersTabsText,
scope: me,
handler: me.onCloseOthers
});
}
if (me.showCloseAll) {
items.push({
itemId: 'closeAll',
text: me.closeAllTabsText,
scope: me,
handler: me.onCloseAll
});
}
if (me.extraItemsHead) {
items = me.extraItemsHead.concat(items);
}
if (me.extraItemsTail) {
items = items.concat(me.extraItemsTail);
}
me.menu = Ext.create('Ext.menu.Menu', {
items: items,
listeners: {
hide: me.onHideMenu,
scope: me
}
});
}
return me.menu;
},
onHideMenu: function () {
var me = this;
me.fireEvent('aftermenu', me.menu, me);
},
onClose : function(){
this.tabPanel.remove(this.item);
},
onCloseOthers : function(){
this.doClose(true);
},
onCloseAll : function(){
this.doClose(false);
},
doClose : function(excludeActive){
var items = [];
this.tabPanel.items.each(function(item){
if(item.closable){
if(!excludeActive || item != this.item){
items.push(item);
}
}
}, this);
Ext.suspendLayouts();
Ext.Array.forEach(items, function(item){
this.tabPanel.remove(item);
}, this);
Ext.resumeLayouts(true);
}
});
❸ Extjs:关于关闭TabPanel标签的问题
取得窗口的引用
在下一个窗口打开时
用前一个窗口的引用关闭
❹ extjs 如何关闭当前整个网页
Extjs中关闭整个页面需要用parent对象窗口打开的window对象。
例如:
有a,b两个页面,a页面为主页面,有按钮一个,点击按钮弹出一个windows对象,在其中显示b页面。b页面中也有一个按钮,点击关闭窗口。
a.htm (部分代码)
<script type="text/javascript">
function openWindow(id,title,url,width,height){
var win = Ext.get(id)
if (win) {
win.close();
return;
}
win = new Ext.Window({
id:id,
title:title,
layout:'fit',
width:width,
height:height,
closeAction:'close',
collapsible:true,
plain: false,
resizable: true,
html : ''
});
win.show();
}
function myfunction(){
openWindow('b-win','窗口中打开b页面','b.htm',400,300);
}
</script>
<input type="button" name="button1" value="打开窗口" onClick="myfunction()">
b.htm(部分代码)
<script type="text/javascript">
function closewin(){
var win = parent.Ext.getCmp('b-win');
if (win) {win.close();}
}
</script>
<input type="button" name="button1" value="关闭a打开的窗口" onClick="closewin()">