[CLOSED] How to disable toolbar buttons or hide toolbar TablePanel when all the tabs are closed

  1. #1

    [CLOSED] How to disable toolbar buttons or hide toolbar TablePanel when all the tabs are closed

    Hi,

    I have a TabPanel with Toolbar buttons. I have attached the "TabCloseMenu" plugin to my TabPanel. Now when the "Close All Tabs" menu is clicked all the tabs are getting closed. Now, how can i disable all the buttons of Toolbar or hide the toolbar of TabPanel.

    Regards,
    Manoj.
    Last edited by Daniil; May 25, 2011 at 9:14 AM. Reason: [CLOSED]
  2. #2
    Hi,

    You can use the TabPanel's TabClose listener.
    <TabClose Handler="if (this.items.getCount() === 1) {
                           Toolbar1.hide();
                       }" />
  3. #3
    Daniil,

    Thank you. In what listener do i need to show the toolbar again?.

    Regards,
    Manoj.
  4. #4
    I'd suggest to use Add listener.

    Here is the full example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ 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 Example</title>
        
         <script type="text/javascript">
            var addTab = function (tabPanel, id, url) {
                var tab = tabPanel.getComponent(id);
    
                if (!tab) {
                    tab = tabPanel.add({ 
                        id       : id, 
                        title    : url, 
                        closable : true,                    
                        autoLoad : {
                            showMask : true,
                            url      : url,
                            mode     : "iframe",
                            maskMsg  : "Loading " + url + "..."
                        }                    
                    });
    
                    tab.on("activate", function () {
                        var item = MenuPanel1.menu.items.get(id + "_item");
                        
                        if (item) {
                            MenuPanel1.setSelection(item);
                        }
                    }, this);
                }
                
                tabPanel.setActiveTab(tab);
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Window 
                runat="server" 
                Width="700" 
                Height="500" 
                Icon="Link" 
                Title="Adding tab">
                <Items>
                    <ext:BorderLayout runat="server">
                        <West>
                            <ext:MenuPanel ID="MenuPanel1" runat="server" Width="200">
                                <Menu runat="server">
                                    <Items>
                                        <ext:MenuItem ID="idClt_item" runat="server" Text="Ext.Net">
                                            <Listeners>
                                                <Click Handler="addTab(#{TabPanel1}, 'idClt', 'http://www.ext.net');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                        
                                        <ext:MenuSeparator />
                                        
                                        <ext:MenuItem ID="idGgl_item" runat="server" Text="Google">
                                            <Listeners>
                                                <Click Handler="addTab(#{TabPanel1}, 'idGgl', 'http://www.google.com');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                        
                                        <ext:MenuSeparator />
                                        
                                        <ext:MenuItem ID="idExt_item" runat="server" Text="ExtJS">
                                            <Listeners>
                                                <Click Handler="addTab(#{TabPanel1}, 'idExt', 'http://www.extjs.com');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </Menu>
                            </ext:MenuPanel>
                        </West>
                        <Center>
                            <ext:TabPanel ID="TabPanel1" runat="server">
                                <TopBar>
                                    <ext:Toolbar runat="server">
                                        <Items>
                                            <ext:Button runat="server" Text="Button" StandOut="true" />
                                        </Items>
                                        <Listeners>
                                            <AfterRender Handler="this.hide();" />
                                        </Listeners>
                                    </ext:Toolbar>
                                </TopBar>
                                <Plugins>
                                    <ext:TabCloseMenu />
                                </Plugins>
                                <Listeners>
                                    <AfterRender Handler="this.on('add', function () {
                                                              this.getTopToolbar().show();   
                                                          });" />
                                    <TabClose Handler="if (this.items.getCount() === 1) {
                                                           this.getTopToolbar().hide();
                                                       }" />
                                </Listeners>
                            </ext:TabPanel>                          
                        </Center>
                    </ext:BorderLayout>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
  5. #5
    Daniil,

    Thank you for the full example. Now i am able to fix my problem.

    Regards,
    Manoj.
  6. #6
    Daniil,

    The TabPanel height is not getting adjusted if you hide the toolbar. You can see in the sample which you have provided. It gets adjusted only if you try to resize the window.

    Regards,
    Manoj.
  7. #7
    Call .doLayout() for the Window.
  8. #8
    Daniil,

    Thank you.

    Regards,
    Manoj.

Similar Threads

  1. [CLOSED] Hide paging toolbar buttons
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 24, 2011, 2:01 PM
  2. [CLOSED] Center buttons in a toolbar
    By wazige in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 06, 2010, 12:36 PM
  3. [CLOSED] Silver buttons in toolbar
    By chafikb in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 09, 2010, 11:16 AM
  4. [CLOSED] Toolbar Align Buttons
    By CMA in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 18, 2009, 5:25 AM
  5. Problems with toolbar buttons
    By flaviodamaia in forum 1.x Help
    Replies: 6
    Last Post: Jan 07, 2009, 3:05 PM

Posting Permissions