[CLOSED] setActiveTab with disabled TabPanel

  1. #1

    [CLOSED] setActiveTab with disabled TabPanel

    Hi,

    When setActiveTab between tabs with disabled TabPanel, show content's tab of activeTab but selects the previous tab.

    Example:

    <ext:Panel runat="server" Layout="VBoxLayout">
        <Items>
            <ext:Button runat="server" Icon="DoorIn" ToolTip="Tooltip">
                <Listeners>
                    <Click Handler="
                        mainTabPanel.setActiveTab(tab1); 
                        mainTabPanel.setDisabled(true); 
                        mainTabPanel.setActiveTab(tab2);
                        mainTabPanel.setDisabled(false);" />
                    </Listeners>
                </ext:Button>
                <ext:TabPanel ID="mainTabPanel" runat="server" Border="false" Region="Center" DeferredRender="false">
                    <Items>
                        <ext:Panel ID="tab1" runat="server" Border="false" Title="Tab1" Layout="FitLayout">
                            <Items>
                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <LayoutConfig>
                                        <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                                    </LayoutConfig>
                                    <Items>
                                        <ext:Label runat="server" Text="TAB1" />
                                    </Items>
                                </ext:Container>
                            </Items>
                            <Listeners>
                                <BeforeRender Handler="top.Trace['StartOpenTab'] = new Date();" />
                            </Listeners>
                        </ext:Panel>
                        <ext:Panel ID="tab2" runat="server" Border="false" Title="Tab2" Layout="FitLayout">
                            <Items>
                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <LayoutConfig>
                                        <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                                    </LayoutConfig>
                                    <Items>
                                        <ext:Label runat="server" Text="TAB2" />
                                    </Items>
                                </ext:Container>
                            </Items>
                            <Listeners>
                                <BeforeRender Handler="top.Trace['StartOpenTab'] = new Date();" />
                            </Listeners>
                        </ext:Panel>
                        <ext:Panel ID="tab3" runat="server" Border="false" Title="Tab3" Layout="FitLayout">
                            <Items>
                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <LayoutConfig>
                                        <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                                    </LayoutConfig>
                                    <Items>
                                        <ext:Label runat="server" Text="TAB3" />
                                    </Items>
                                </ext:Container>
                            </Items>
                            <Listeners>
                                <BeforeRender Handler="top.Trace['StartOpenTab'] = new Date();" />
                            </Listeners>
                        </ext:Panel>
                    </Items>
                </ext:TabPanel>
        </Items>
    </ext:Panel>
    How can fix it?

    Greetings,
    Last edited by Daniil; Oct 08, 2013 at 6:44 AM. Reason: [CLOSED]
  2. #2
    Hi @softmachine2011,

    I think it is not a defect. A setActiveTab method should not be called if a TabPanel is disabled.

    You can add a condition if needed.

    if (!tabPanel.isDisabled()) {
        tabPanel.setActiveTab(tab);
    }
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @softmachine2011,

    I think it is not a defect. A setActiveTab method should not be called if a TabPanel is disabled.

    You can add a condition if needed.

    if (!tabPanel.isDisabled()) {
        tabPanel.setActiveTab(tab);
    }
    Hi Daniil,

    I think it really is a bug. If you really could not call the function, would not make anything.

    But i need change Tab when tabPanel is disabled. Is there any way to do this?

    Thanks,
  4. #4
    Quote Originally Posted by softmachine2011 View Post
    I think it really is a bug. If you really could not call the function, would not make anything.
    Do you think the "active tab" term is actual for a disabled TabPanel? Well, I don't think so. If it needs to set up an active tab for a disabled TabPanel, maybe, there is something wrong in the design.

    I am not sure what you mean here:
    If you really could not call the function, would not make anything.
    Could you, please, clarify?

    Quote Originally Posted by softmachine2011 View Post
    But i need change Tab when tabPanel is disabled. Is there any way to do this?
    An Enable listener can help to set up an active tab when a disabled TabPanel becomes enabled.
  5. #5
    Hi,
    I also have a requirement to change the tab of a disabled tabpanel.

    I have one active tabpanel and i have another tabpanel that is enabled but within a panel that is disabled.
    I want to keep the 2 tabpanels synced. So when i change the left tab i want to do the same with the right tabpanel.
    But when the right panel is enabled again the tabpanel has the correct panel showing but the tab is still the one that was selected before it was disabled. The tab that is meant to be selected now does nothing when clicked.

    I am wondering why when the tabpanel is not disabled but under a disabled parent why it will not change tab correctly.

    I have this requirement in a few places and is proving difficult to add an enable listener to set the tab.

    Is there any other way around this?

    Thanks
    Fergus
  6. #6
    Hello!

    You can try to override this behavior. Take a look at this sample:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    
    </head>
    <body>
        <ext:ResourceManager runat="server" ScriptMode="Debug" />
    
        <script>
            Ext.override(Ext.tab.Bar, {
                setActiveTab: function (tab, initial) {
                    var me = this;
                    if (tab !== me.activeTab) {
                        if (me.activeTab) {
                            if (me.activeTab.isDestroyed) {
                                me.previousTab = null;
                            } else {
                                me.previousTab = me.activeTab;
                                me.activeTab.deactivate();
                            }
                        }
                        tab.activate();
                        me.activeTab = tab;
                        me.needsScroll = true;
                        if (!initial) {
                            me.fireEvent('change', me, tab, tab.card);
                            me.updateLayout();
                        }
                    }
                }
            });
        </script>
    
        <ext:Button runat="server" ID="Button1" Text="Activate second tab">
            <Listeners>
                <Click Handler="
                    App.mainTabPanel.setActiveTab(1);
                    App.mainTabPanel.tabBar.setActiveTab(App.mainTabPanel.getComponent(1).tab);
                    ">
                </Click>
            </Listeners>
        </ext:Button>
    
        <ext:TabPanel ID="mainTabPanel" runat="server" Border="false" Region="Center" DeferredRender="false" Disabled="True">
            <Items>
                <ext:Panel ID="tab1" runat="server" Border="false" Title="Tab1" Layout="FitLayout">
                    <Items>
                        <ext:Container runat="server" Layout="HBoxLayout">
                            <LayoutConfig>
                                <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                            </LayoutConfig>
                            <Items>
                                <ext:Label runat="server" Text="TAB1" />
                            </Items>
                        </ext:Container>
                    </Items>
                    <Listeners>
                    </Listeners>
                </ext:Panel>
                <ext:Panel ID="tab2" runat="server" Border="false" Title="Tab2" Layout="FitLayout">
                    <Items>
                        <ext:Container runat="server" Layout="HBoxLayout">
                            <LayoutConfig>
                                <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                            </LayoutConfig>
                            <Items>
                                <ext:Label runat="server" Text="TAB2" />
                            </Items>
                        </ext:Container>
                    </Items>
                    <Listeners>
                    </Listeners>
                </ext:Panel>
                <ext:Panel ID="tab3" runat="server" Border="false" Title="Tab3" Layout="FitLayout">
                    <Items>
                        <ext:Container runat="server" Layout="HBoxLayout">
                            <LayoutConfig>
                                <ext:HBoxLayoutConfig Align="Middle" Pack="Center" />
                            </LayoutConfig>
                            <Items>
                                <ext:Label runat="server" Text="TAB3" />
                            </Items>
                        </ext:Container>
                    </Items>
                    <Listeners>
                    </Listeners>
                </ext:Panel>
            </Items>
        </ext:TabPanel>
    </body>
    </html>

Similar Threads

  1. SetActiveTab in GroupTabPanel
    By Rupesh in forum 1.x Help
    Replies: 4
    Last Post: Dec 11, 2010, 12:16 PM
  2. Tab - Autoload - setActiveTab After Tab loaded
    By Tbaseflug in forum 1.x Help
    Replies: 4
    Last Post: Jun 17, 2009, 4:39 PM
  3. Replies: 0
    Last Post: Apr 09, 2009, 5:12 PM
  4. [FIXED] [V0.6] TabPanel and SetActiveTab
    By Timothy in forum Bugs
    Replies: 2
    Last Post: Sep 10, 2008, 7:35 AM
  5. [CLOSED] TabPanel.SetActiveTab with PostBack
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jul 14, 2008, 12:38 PM

Posting Permissions