ExtJs4.2中Tab选项卡的右击关闭其它和关闭当前功能不准确的解决方法
一、ExtJs4.2中Tab选项卡的右击关闭其它和关闭当前功能不准确的解决方法

二、找到ux目录下的TabCloseMenu.js文件,将内容替换成下面代码。
三、代码:
/**
* 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',
showCloseOthers: true,
closeOthersTabsText: 'Close Other Tabs', /**
* @cfg {Boolean} showCloseAll
* Indicates whether to show the 'Close All' option.
*/
showCloseAll: true,
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, //public
constructor: function (config) {
this.addEvents(
'aftermenu',
'beforemenu'); 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); this.item = me.tabPanel.getComponent(index);
me.selectedTab = me.tabPanel.getComponent(index);
menu.child('*[text="' + me.closeTabText + '"]').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('*[text="' + me.closeAllTabsText + '"]').setDisabled(disableAll);
} if (me.showCloseOthers) {
menu.child('*[text="' + me.closeOthersTabsText + '"]').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 = [{
text: me.closeTabText,
scope: me,
handler: me.onClose
}]; if (me.showCloseAll || me.showCloseOthers) {
items.push('-');
} if (me.showCloseOthers) {
items.push({
text: me.closeOthersTabsText,
scope: me,
handler: me.onCloseOthers
});
} if (me.showCloseAll) {
items.push({
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.item = null;
me.fireEvent('aftermenu', me.menu, me);
}, onClose: function () {
this.tabPanel.remove(this.selectedTab);
}, 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.selectedTab) {
items.push(item);
}
}
}, this); Ext.each(items, function (item) {
this.tabPanel.remove(item);
}, this);
}
});
ExtJs4.2中Tab选项卡的右击关闭其它和关闭当前功能不准确的解决方法的更多相关文章
- WPF:指定的命名连接在配置中找不到、非计划用于 EntityClient 提供程序或者无效的解决方法
文/嶽永鹏 WPF 数据绑定中绑定到ENTITY,如果把数据文件做成一个类库,在UI文件中去应用它,可能遇到下面这种情况. 指定的命名连接在配置中找不到.非计划用于 EntityClient 提供程序 ...
- zend studio中ctrl+鼠标左键无法转到类或函数定义文件的解决方法
转载自:http://blog.csdn.net/wide288/article/details/21622183 zend studio中ctrl+鼠标左键无法转到类或函数定义文件的解决方法: ze ...
- Bootstrap Modal 关闭时右侧滚动条消失,页面左移的解决方法
问题描述:页面在打开Modal之前右侧有滚动条,Modal关闭之后,body中的class="modal-open"和style="padding-right: 17px ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- 网页中"IE限制网页访问脚本或ActiveX控件"的提示问题的解决方法
以前从来没有注意过"IE限制网页访问脚本或ActiveX控件"的提示问题,对于这个小细节问题,虽然感觉很别扭,但一直没考虑解决方法,今天才发现该问题可以轻松解决,以下做个小小记录. ...
- iframe中使用模态框提交表单后,iframe加载父页面的解决方法
在iframe中使用模态框提交表单后,会出现iframe加载整个父页面的问题,如下图: 解决方法: 在form表单中添加target属性 _parent 这个属性会使目标文档载入父窗口或者包含来超链接 ...
- Android开发中怎样用多进程、用多进程的好处、多进程的缺陷、解决方法(转)
转自:http://blog.csdn.net/spencer_hale/article/details/54968092 1.怎样用多进程 Android多进程概念:一般情况下,一个应用程序就是一个 ...
- Centos7.5中Nginx报错:nginx: [error] invalid PID number "" in "/run/nginx.pid" 解决方法
服务器重启之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number "" ...
- NS2中couldn‘t read file “../tcl/mobility/scene/cbr-3-test“: no such file or directory解决方法
运行wireless.tcl 文件时报错:couldn't read file "../../uAMPS/ns-leach.tcl": no such file or direct ...
随机推荐
- mariadb设置初始密码
mariadb设置初始密码 CENTOS7 自带MARIADB数据库.安装的时候可以勾选安装. 当然也可以以后在CENTOS7里面添加安装. MARIADB安装后,默认是没有密码的. 我们需要给ROO ...
- NSNotification的使用(对观察者模式最通俗、易懂的讲解)
这是一个观察者模式. 首先在你需要监听的类中加入观察者: - (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString ...
- SharePoint Online 创建列表库
前言 本文介绍如何在Office 365中创建列表库,以及列表库的一些基本设置. 正文 通过登录地址登录到Office 365的SharePoint Online站点中,我们可以在右上角的设置菜单中, ...
- 超感猎杀/超感八人组第一季至二季/全集Sense8迅雷下载
本季 Sense8 (2015)看点:<超感八人组>由沃卓斯基姐弟执导的科幻剧集是Netflix继“纸牌屋第二季”后的又一大手笔制作,讲述未来世界不同地区的8个人因同时目睹同一暴力事件.从 ...
- 美国罪案故事第一季/全集American Crime Story迅雷下载
英文全名American Crime Story,第1季(2016)FX.本季看点:<美国罪案故事>以律师们的视角看待辛普森谋杀案. 本剧探索了案件背后各种混乱,以及案件双方的庭审策略,也 ...
- 黑帆第四季/全集Black Sails迅雷下载
本季看点:<黑帆>本剧是著名海盗故事<金银岛>(Treasure Island)的前传.Starz宣布<Black Sails>已提前获得第四季续订,第四季10集和 ...
- 解决appcompat中各种奇葩的错误
一.依赖/脱离appcompat 在新版本中Google跟新了一个依赖包,这个包包含了v4和v7的东西(v7是要依赖v4这个包的,所以用到v7时必须用一起的v4),只要你的编译版本compile wi ...
- Orchard模块开发全接触4:深度改造前台
这里,我们需要做一些事情,这些事情意味着深度改造前台: 1:为商品增加 添加到购物车 按钮,点击后功能实现: 2:商品排序: 3:购物车预览,以及添加 结算 按钮: 4:一个显式 购物车中有*个 商品 ...
- 将java中数组转换为ArrayList的方法实例(包括ArrayList转数组)
方法一:使用Arrays.asList()方法 1 2 String[] asset = {"equity", "stocks", "gold&q ...
- [转]MongoDB基本使用
转自 : http://www.cnblogs.com/TankMa/archive/2011/06/08/2074947.html 成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可 ...