[CLOSED] Insert tab at Position (n) on TabPanel

  1. #1

    [CLOSED] Insert tab at Position (n) on TabPanel

    When creating a new tab in my tab panel, I'd like to have it always open/insert the tab directly to the right of the active tab. It seems the default behaviour is to always open/insert the tab at the far right/end of the tabs. Is there a way to add a new tab and then have it appear directly to the right of the ActiveTab (similar to how the IE browser handles tabs)?

    <%@ Page Language="vb"%>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script language="javascript">
    
    
    
        function addTab() {
            var index = TabPanel1.items.length;
            var title = "Tab" + index;
            var id = "Tab" + index;
            var tab = TabPanel1.add({
                id: id,
                title: title,
                closable: true,
                showIFrameMask: true
            });
            TabPanel1.setActiveTab(tab);
            tab.loadIFrame('http://www.ext.net');
        }    
    
    
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" InitScriptMode="Inline">
        </ext:ScriptManager>        
                
        <ext:ViewPort ID="ViewPort1" runat="server">
            <Body>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <West Collapsible="true" Split="false">
                    </West>
                    <Center>
                          <ext:Panel ID="Panel7" runat="server" AutoScroll="true">
                            <Body>
                                <ext:FitLayout ID="FitLayout2" runat="server">
                                    <ext:TabPanel ID="TabPanel1" Border="false" runat="server" ActiveTabIndex="0" Plain="true" LayoutOnTabChange="true" EnableTabScroll="true">
                                        <TopBar>
                                            <ext:Toolbar runat="server">
                                                <Items>
                                                    <ext:ToolbarButton Text="New Tab" Icon="Add">
                                                        <Listeners>
                                                            <Click Handler="addTab();" />
                                                        </Listeners>
                                                    </ext:ToolbarButton>
                                                </Items>
                                            </ext:Toolbar>
                                        </TopBar>
                                        <Tabs>        
                                            <ext:Tab ID="Tab0" Title="Tab0" runat="server" Closable="true" ShowIFrameMask="true" AutoScroll="true">
                                                <AutoLoad Url="http://yahoo.com"></AutoLoad>
                                            </ext:Tab>                                      
                                            <ext:Tab ID="Tab1" Title="Tab1" runat="server" Closable="true" ShowIFrameMask="true" AutoScroll="true">
                                                <AutoLoad Url="http://google.com"></AutoLoad>
                                            </ext:Tab>                                                                                                                  
                                        </Tabs>
                                    </ext:TabPanel>   
                                </ext:FitLayout>
                            </Body>
                        </ext:Panel>
                    </Center>
                </ext:BorderLayout>
            </Body>
       </ext:ViewPort>              
    </form>
    </body>
    </html>
    Last edited by geoffrey.mcgill; Feb 22, 2011 at 4:32 AM.
  2. #2

    RE: [CLOSED] Insert tab at Position (n) on TabPanel

    Hi,

    Use 'insert' instead 'add'.


    insert(index, tab)


    To get active tab index use:


    Tabs.items.indexOf(Tabs.getActiveTab());
  3. #3

    RE: [CLOSED] Insert tab at Position (n) on TabPanel



    Perfect... thank you very much.

    please mark as [CLOSED]

Similar Threads

  1. Replies: 2
    Last Post: Mar 19, 2012, 11:08 AM
  2. Replies: 11
    Last Post: Feb 29, 2012, 3:57 PM
  3. [CLOSED] insert record
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 12, 2010, 4:08 PM
  4. Replies: 3
    Last Post: Aug 21, 2009, 2:24 PM
  5. TabPanel tabs start position
    By aghanem in forum 1.x Help
    Replies: 5
    Last Post: Apr 26, 2009, 5:03 PM

Posting Permissions