我为Ext.tab.Panel
. 我希望这可以帮助你。
更新
- 现在像预期的那样工作:)
- badgeCls 不能将数组作为参数(如果您想要此功能,请告诉我;))
覆盖:
Ext.define('My.tab.Panel', {
override: 'Ext.tab.Panel',
onItemAdd: function(card) {
var me = this;
if (!card.isInnerItem()) {
return me.callParent(arguments);
}
var tabBar = me.getTabBar(),
initialConfig = card.getInitialConfig(),
tabConfig = initialConfig.tab || {},
tabTitle = (card.getTitle) ? card.getTitle() : initialConfig.title,
tabIconCls = (card.getIconCls) ? card.getIconCls() : initialConfig.iconCls,
tabHidden = (card.getHidden) ? card.getHidden() : initialConfig.hidden,
tabDisabled = (card.getDisabled) ? card.getDisabled() : initialConfig.disabled,
tabBadgeText = (card.getBadgeText) ? card.getBadgeText() : initialConfig.badgeText,
tabBadgeCls = (card.getBadgeCls) ? card.getBadgeCls() : initialConfig.badgeCls,
innerItems = me.getInnerItems(),
index = innerItems.indexOf(card),
tabs = tabBar.getItems(),
activeTab = tabBar.getActiveTab(),
currentTabInstance = (tabs.length >= innerItems.length) && tabs.getAt(index),
tabInstance;
if (tabTitle && !tabConfig.title) {
tabConfig.title = tabTitle;
}
if (tabIconCls && !tabConfig.iconCls) {
tabConfig.iconCls = tabIconCls;
}
if (tabHidden && !tabConfig.hidden) {
tabConfig.hidden = tabHidden;
}
if (tabDisabled && !tabConfig.disabled) {
tabConfig.disabled = tabDisabled;
}
if (tabBadgeText && !tabConfig.badgeText) {
tabConfig.badgeText = tabBadgeText;
}
if (tabBadgeCls && !tabConfig.badgeCls) {
tabConfig.badgeCls = Ext.baseCSSPrefix + 'badge ' + tabBadgeCls;
}
//<debug warn>
if (!currentTabInstance && !tabConfig.title && !tabConfig.iconCls) {
if (!tabConfig.title && !tabConfig.iconCls) {
Ext.Logger.error('Adding a card to a tab container without specifying any tab configuration');
}
}
//</debug>
tabInstance = Ext.factory(tabConfig, Ext.tab.Tab, currentTabInstance);
if (!currentTabInstance) {
tabBar.insert(index, tabInstance);
}
card.tab = tabInstance;
me.callParent(arguments);
if (!activeTab && activeTab !== 0) {
tabBar.setActiveTab(tabBar.getActiveItem());
}
}
});