Well, I'm adding tabs dynamically and I don't know how to use your code.
When you say
tab.tab.hide();
I understand that, first 'tab' is tabPanel id, and the second 'tab' is tab id to close but I can't do it because tab id is dynamic.
This is how I add tabs to the tabpanel, and in beforeclose event I control if tab is only hidden or closed.
openTab: function (config) {
if (Ext.isEmpty(config.url, false)) {
return;
}
var tp = Ext.getCmp("tpMain");
var tabId = MyNamespace.tabIdPrefix + MyNamespace.hashCode(config.url).toString();
var tab = tp.getComponent(tabId);
if (!tab) {
tab = tp.add({
id: tabId,
title: config.title,
iconCls: config.icon || "icon-applicationdouble",
onBeforeCloseTab: config.onBeforeCloseTab ? config.onBeforeCloseTab : null,
anyDetailOpened: false,
closable: true,
closeAction: 'close',
loader: {
url: config.url,
renderer: 'frame',
noCache: true,
loadMask: {
showMask: true,
msg: 'Loading'
},
listeners: {
load: function (control) {
control.target.iframe.dom.contentWindow.parentTab = control.target;
}
}
}
});
tp.setActiveTab(tab);
tab.addListener('activate', tab.syncSize);
tab.on("beforeclose", function (tab, windowCloseRequest) {
var someCondition = true; //Dummy for this example
if(someCondition == true){
tab.closeRequest = true;
var tpMain = top.Ext.getCmp("tpMain");
/**** HERE IS THE PROBLEM TO HIDE TABS ***/
tab.hide();
tpMain.hideTabStripItem(tab);
var tabInicio = top.Ext.getCmp("tabInicio");
tpMain.setActiveTab(tabInicio);
return false;
}
});
} else {
tab.closeRequest = false;
tp.setActiveTab(tab);
tab.fireEvent('activate');
Ext.get(tab.tab.el).frame();
}
},