一、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选项卡的右击关闭其它和关闭当前功能不准确的解决方法的更多相关文章

  1. WPF:指定的命名连接在配置中找不到、非计划用于 EntityClient 提供程序或者无效的解决方法

    文/嶽永鹏 WPF 数据绑定中绑定到ENTITY,如果把数据文件做成一个类库,在UI文件中去应用它,可能遇到下面这种情况. 指定的命名连接在配置中找不到.非计划用于 EntityClient 提供程序 ...

  2. zend studio中ctrl+鼠标左键无法转到类或函数定义文件的解决方法

    转载自:http://blog.csdn.net/wide288/article/details/21622183 zend studio中ctrl+鼠标左键无法转到类或函数定义文件的解决方法: ze ...

  3. Bootstrap Modal 关闭时右侧滚动条消失,页面左移的解决方法

    问题描述:页面在打开Modal之前右侧有滚动条,Modal关闭之后,body中的class="modal-open"和style="padding-right: 17px ...

  4. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  5. 网页中"IE限制网页访问脚本或ActiveX控件"的提示问题的解决方法

    以前从来没有注意过"IE限制网页访问脚本或ActiveX控件"的提示问题,对于这个小细节问题,虽然感觉很别扭,但一直没考虑解决方法,今天才发现该问题可以轻松解决,以下做个小小记录. ...

  6. iframe中使用模态框提交表单后,iframe加载父页面的解决方法

    在iframe中使用模态框提交表单后,会出现iframe加载整个父页面的问题,如下图: 解决方法: 在form表单中添加target属性 _parent 这个属性会使目标文档载入父窗口或者包含来超链接 ...

  7. Android开发中怎样用多进程、用多进程的好处、多进程的缺陷、解决方法(转)

    转自:http://blog.csdn.net/spencer_hale/article/details/54968092 1.怎样用多进程 Android多进程概念:一般情况下,一个应用程序就是一个 ...

  8. Centos7.5中Nginx报错:nginx: [error] invalid PID number "" in "/run/nginx.pid" 解决方法

    服务器重启之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number "" ...

  9. 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 ...

随机推荐

  1. ZServer4D开源项目

    ZServer4D开源项目 ZServer4D 是一套从商业项目剥离而出的云服务器中间件,可以承载百万级的分布式负载服务,并且支持IoT及内网穿透. 作者将它开源了 https://github.co ...

  2. Android SDK代理服务器解决国内不能更新下载问题

    原文地址:http://blog.csdn.net/boonya/article/details/38752647 读者须知:本篇文章中最靠谱的是第三种方式,最近有读者反映第三种方式也不行了,下面提供 ...

  3. 【Centos】centos查看磁盘使用情况

    1.查看分区和磁盘 lsblk 查看分区和磁盘 2.查看空间使用情况 df -h 查看空间使用情况 3.分区工具查看分区信息 fdisk -l 分区工具查看分区信息 4.查看分区 cfdisk /de ...

  4. Java编解码分析

    一.为什么要编解码? 网络或磁盘传输的单位都是字节,平常我们使用的单位都是字符,所以数据需要在字节和字符之间进行转换. 二.编解码概念 1.编码:字符转换成字节 2.解码:字节转换成字符 三.常用字符 ...

  5. 解决appcompat中各种奇葩的错误

    一.依赖/脱离appcompat 在新版本中Google跟新了一个依赖包,这个包包含了v4和v7的东西(v7是要依赖v4这个包的,所以用到v7时必须用一起的v4),只要你的编译版本compile wi ...

  6. Chapter 5 -- ImmutableCollections

    Example publicstatic final ImmutableSet<String> COLOR_NAMES =ImmutableSet.of(  "red" ...

  7. 使用Log4j将程序日志实时写入Kafka(转)

    原文链接:使用Log4j将程序日志实时写入Kafka 很多应用程序使用Log4j记录日志,如何使用Kafka实时的收集与存储这些Log4j产生的日志呢?一种方案是使用其他组件(比如Flume,或者自己 ...

  8. C C++ 去除 unused的提示

    C C++ 去除 unused的提示 #define UNUSED(VAR) {VAR++;VAR--;} unsigned int user_id=0; UNUSED(user_id); 这样就可以 ...

  9. secureCRT在Windows上面的安装过程

    参考这篇文章: https://www.cnblogs.com/yjd_hycf_space/p/7729796.html

  10. SharePoint _layouts下自定义程序页面权限管理

    在sharepoint中,_layouts下的自定义页面没有特别的权限,只要用户能访问sharepoint站点就可以访问_layouts下的自定义程序页面,现在我们需要给自定义页面做一下权限认证.要求 ...