Jul 02, 2010, 2:49 PM
[CLOSED] [1.0] TabPanel - Solution for no TabChange on Page_Load
I thought I would share my solution for stopping the TabChange listener only on Page_Load - I want it to fire any other time.
As suggested in other posts, I use the BeforeTabChange to stop the firing on the page_load, but I do it by using the single property instead of whether or not something is visible. The 1 issue I ran into with this is that the active tab does not change to active because the setActiveTab function does not run that section of code if BeforeTabChange returns false. So I added a new function to Ext.TabPanel that will set the tab to active.
markup: (tabs are added and set as active in code-behind)
Thanks~
As suggested in other posts, I use the BeforeTabChange to stop the firing on the page_load, but I do it by using the single property instead of whether or not something is visible. The 1 issue I ran into with this is that the active tab does not change to active because the setActiveTab function does not run that section of code if BeforeTabChange returns false. So I added a new function to Ext.TabPanel that will set the tab to active.
markup: (tabs are added and set as active in code-behind)
<ext:TabPanel ID="tabPanel1" runat="server">
<Listeners>
<BeforeTabChange Handler="this.setActiveTabClass(newTab); return false;" Single="true" />
<TabChange Handler="searchExecuted();" />
</Listeners>
</ext:TabPanel>
jsScript:Ext.override(Ext.TabPanel, {
setActiveTabClass: function(item) {
item = this.getComponent(item);
if(item){
var el = this.getTabEl(item);
Ext.fly(el).addClass('x-tab-strip-active');
this.activeTab = item;
this.stack.add(item);
this.layout.setActiveItem(item);
if(this.scrolling){
this.scrollToTab(item, this.animScroll);
}
}
}
});
If anyone has a better solution please let me know.Thanks~
Last edited by geoffrey.mcgill; Jul 07, 2010 at 2:49 AM.