[CLOSED] ext:TabPanel: adding controls in JavaScript.

  1. #1

    [CLOSED] ext:TabPanel: adding controls in JavaScript.

    Hi!

    I'm adding controls in tabPanel with Javascript.
    My problem may seem confusing at first ... I am wanting to create exactly the same controls on each tab, with the same IDs.
    If I add one tab, works fine.
    If I add the second tab, I get problems.
    I think it´s occurs because the Id are the same.

    It is important to me that the controls have the same id. Is there any way I can create the controls and they become 'encapsulated' in the tab, without interference from the other tab controls?

    I made a simple project to explain my problem... To test, add tabs and click in Delete button, for example.

    <%@ Page Language="vb" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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 runat="server">
        <title>Ext.net test</title>
    
        <script type="text/javascript">
            var getTab = function() {
                
                //monta o panel
                vPane = {
                    id: "panelTab",
                    flex: 1,
                    //items: getGridPanel(xConf, xConf.activeQuery),
                    layout: "fit",
                    tbar: getTabBar()
                };
    
                return vPane;
    
            };
    
            var getTabBar = function() {
                //1 - monta as barras
                var tbXW = {
                    id: "tbWebExplorer",
                    xtype: "toolbar",
                    items: []
                };
    
                //btnAdd
                tbXW.items.push({
                    id: "btnAdd",
                    iconCls: "#ApplicationAdd",
                    text: "Adicionar",
                    tooltip: "Adicionar registro",
                    listeners: {
                        click: {
                            fn: function (item, e) {
                                alert('btnAdd clicked');
                            }
                        }
                    }
                });
    
                //btnEdit
                tbXW.items.push({
                    id: "btnEdit",
                    iconCls: "#ApplicationEdit",
                    text: "Editar",
                    tooltip: "Editar registro selecionado",
                    listeners: {
                        click: {
                            fn: function (item, e) {
                                alert('btnEdit clicked');
                            }
                        }
                    }
                });
    
                //btnDelete
                tbXW.items.push({
                    id: "btnDelete",
                    iconCls: "#ApplicationDelete",
                    text: "Excluir",
                    tooltip: "Deletar registro(s) selecionados",
                    listeners: {
                        click: {
                            fn: function (item, e) {
                                alert('btnDelete clicked');
                            }
                        }
                    }
                });
    
                return tbXW;
            };
    
            var addTab = function (tabPanel, id, title) {
    
                var tab = tabPanel.getComponent(id);
    
                if (!tab) {
                    tab = tabPanel.add({
                        id: id,
                        title: title,
                        closable: true,
                        items: getTab(),
                        layout: 'fit'
                    });
                }
    
                tabPanel.setActiveTab(tab);
    
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="form1" runat="server">
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
            <Items>
                <ext:Panel ID="panelCenter" runat="server" Region="Center" Flex="1" layout="FitLayout" BodyPadding="6" >
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:Button runat="server" ID="btnAddTab" Text="Add Tab 1" OnClientClick = "addTab(#{tabWebExplorer}, 'tab1', 'Tab 1')" />
                                <ext:Button runat="server" ID="btnAddTab1" Text="Add Tab 2" OnClientClick = "addTab(#{tabWebExplorer}, 'tab2', 'Tab 2')" />
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:TabPanel ID="tabWebExplorer" runat="server" Plain="true" Flex="1" Layout="FitLayout">
                            <Items>
                                <ext:Panel runat="server" ID="paneMyPage" Title="MyPage" Icon="ApplicationHome">
                                </ext:Panel>
                            </Items>
                            <Plugins>
                                <ext:TabScrollerMenu ID="TabScrollerMenu1" runat="server" PageSize="90" />
                            </Plugins>
                        </ext:TabPanel>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>   
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 26, 2012 at 4:45 PM. Reason: [CLOSED]
  2. #2
    It is important to me that the controls have the same id. Is there any way I can create the controls and they become 'encapsulated' in the tab, without interference from the other tab controls?
    The only way would be to have each Tab (Panel) use the <Loader> to load an internal <iframe>. The id's could be the same inside each <iframe>, but must be unique if all used on the same Page.
    Geoffrey McGill
    Founder
  3. #3
    Hi Geoffrey!

    The id's could be the same inside each <iframe>, but must be unique if all used on the same Page
    To follow your suggestion, I need insert my components in a new aspx page and call this page? Or i can adding in Javascript? If yes, How i do this?
  4. #4
    Hi,

    Well, generally, it doesn't matter how you will add components to that iframe page. You can add either in markup or JavaScript.

    If you don't want iframes, I would suggest to look into the itemId functionality.
    http://docs.sencha.com/ext-js/4-0/#!...ent-cfg-itemId
  5. #5
    Hi Daniil

    I think that itemId it's exactly what I need...

    Thanks a lot.
  6. #6
    One more question about this subject...

    And store object? I need change storeId???

    storeId: "Store1"
  7. #7
    Yes, there is no itemId functionality in Store. You have to set up unique ids.

    Or, if it's acceptable, you can avoid setting up ids for Stores and place them as a value of the "store" config option of components. Then you can access these Stores like this:
    grid.getStore();
    comboBox.getStore();
  8. #8
    Hi Daniil!

    Thanks a lot... works fine.

    Thanks;

Similar Threads

  1. [CLOSED] Adding a New Tab to TabPanel
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 30, 2012, 6:38 AM
  2. [CLOSED] [0.8.2] Adding new Tab from Tab into a TabPanel problem
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 22, 2010, 7:20 AM
  3. TabPanel error on adding tab
    By sz_146 in forum 1.x Help
    Replies: 0
    Last Post: Jan 09, 2009, 9:01 AM
  4. Adding tabs to tabpanel in JavaScript
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 0
    Last Post: Dec 04, 2008, 9:20 AM
  5. Adding controls on the fly
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 27, 2008, 5:02 AM

Posting Permissions