PDA

View Full Version : TabPanel setActiveTab event not trigged if already active



maquejp
25 Feb 2010, 11:48 PM
OK,

I have this problem since times but I would like to know if there is better way to do.



var gp_lopdata = new Ext.grid.GridPanel({id: 'gp_lopdata',ds: ds_lop,cm: cm_lop,
stripeRows: true,
frame: true,
border: false,
....
});
gp_lopdata.getSelectionModel().on('rowselect',
function(sm, rowIdx, r) {
Ext.getCmp('tp_lopdata').setActiveTab(0);
});
var tp_lopdata = new Ext.TabPanel({
id: 'tp_lopdata',
title: 'tp_lopdata',
border: false,
frame: true,
autoScroll: true,
enableTabScroll: true,
tabPosition: 'top',
layoutOnTabChange: true,
items: [new Ext.Panel({
id: 'p_lopgriddetoverv',
...
}),
...
});
...
Ext.getCmp('p_lopgriddetoverv').on('activate', function(){Ext.getCmp('p_lopgriddetoverv').load(...)});

My problem is that when I select a row in my grid if the active tab is the first (0) the even activate of it is not thrown so the information of the tab is not updated.

The workaround I use is to activate the second tab then activate the first tab so the event is thrown. Of course, it is not the best way as it launch two server request at that time and only only is enough.


Ext.getCmp('tp_lopdata').setActiveTab(1);
Ext.getCmp('tp_lopdata').setActiveTab(0);


I am pretty sure that a better way to do exist ;)

realjax
26 Feb 2010, 12:32 AM
Force the event to be fired if the current open tab panel is the one you want to update...

Ext.getCmp('tp_lopdata').fireEvent('activate')

maquejp
26 Feb 2010, 12:55 AM
Good one realjax!

As I force always to the first tab when row selecting


Ext.getCmp('tp_lopdata').setActiveTab(0);
Ext.getCmp('tp_lopdata').getActiveTab().fireEvent('activate');


and I do the same for the Tabpanel within tab of the main panel...

Thank you...

I am still listening to other way, if any :)

realjax
26 Feb 2010, 12:59 AM
Good one realjax!

As I force always to the first tab when row selecting



then this should work too:



gp_lopdata.getSelectionModel().on('rowselect',
function(sm, rowIdx, r) {
Ext.getCmp('p_lopgriddetoverv').load(...)
Ext.getCmp('tp_lopdata').setActiveTab(0);
})And you can forget about the activate event entirely...

maquejp
26 Feb 2010, 1:40 AM
I need the activate on each tab to be sure that when the user navigate through the tabs (8), it always received the most up to date information.

Thanks