PDA

View Full Version : Closing a tab in an ext window



planavsky82
6 May 2010, 12:56 PM
Hi,

I would like to write a manual function to close a tab in the ext window. When a tab is "closable", it contains an "x" icon that triggers some function to close the tab. I am trying to figure out what function is fired at this point and am having no luck.

Right now I have this code to get the object of "panel-tab1":

Ext.getCmp('panel-tab1');

Now if I want to do something like disable the tab, that is easy:

Ext.getCmp('panel-tab1').disable();

But I need to do something like:

Ext.getCmp('panel-tab1').close(); ...

... but I cannot find the right function to do this... I have tried .destroy(), .remove(), and nothing is working.

Any ideas?

Thanks...

Ytorres
6 May 2010, 1:54 PM
Hi,

You should use the "beforeclose" event, return false by default and attach it your custom function.

Best,
Yannick

taronja
7 May 2010, 12:14 AM
Try this applied to a button:


{ scope:this,
text: '"Cerrar',
handler: function() {
var tp = Ext.getCmp('content-panel');
var tab = tp.getActiveTab();
if(tab){
tp.remove(tab);
}
},
iconAlign: 'bottom',
width : 50,
iconCls: 'cerrar'
}

planavsky82
7 May 2010, 7:00 AM
Thanks for the help guys... I'll try these out.