PDA

View Full Version : How to detect that a tab panel has all tabs closed by user



maneljn
19 Oct 2012, 9:49 AM
How can i detect with an event firing, in mvc controller, that user has closed all tabs in my tab panel.

Thanks

scottmartin
19 Oct 2012, 10:43 AM
You can check the items in the tabpanel:
tabPanel.items.length

Scott.

maneljn
21 Oct 2012, 11:16 PM
Scott, yes, but wich tabpanel event is fired when a subpanel was closed ???

Farish
21 Oct 2012, 11:57 PM
you can try with the tabchange or beforetabchange events but I am not sure whether it would fire when closing the last tab... give it a try!

maneljn
22 Oct 2012, 12:12 AM
tried with just one subpanel, and not firing when closing subpanel

Farish
22 Oct 2012, 12:16 AM
how about the beforeclose event?

maneljn
22 Oct 2012, 7:09 AM
the only solution i found is to listen all destroy event in all subpanels inside the maintabpanel

something like this



....

init: function() {
var me = this;
me.control({
'esiacademia_view_panelBase , esiacademia_view_tabpanelBase' : {
destroy: me.onSubpanelCerrado
}
});
},

//
// Cuando el usuario cierra un subpanel dentro del tabpanel principal
// si es el último, ocultar el tabpanel para que se vea el logo empresa de fondo
//
onSubpanelCerrado: function(widget, eOpts) {
var mainTabPanel = esiacademiaApp.viewportPrincipal.down('esiacademia_view_mainTabPanel[name="esiacademiaMainTabPanel"]');
if (mainTabPanel) {
if (mainTabPanel.items.length<=0) {
mainTabPanel.setVisible(false);
}
}
},

....