add icon to a Tab

  1. #1

    add icon to a Tab

    i am trying to add icon to a tab when it is generated. I don't get any error message when running the code below. But the icon is not generated.

    Thanks so much for your help.


    
    
    
    function addHomeTab(tabPanel, id, url,icon) {
    
    
    var tab = tabPanel.getComponent(id);
    
    
    if (!tab) {
    
    
    tab = tabPanel.add({
    
    
    id: id,
    
    
    title: id,
    
    
    closable: false,
    
    
    iconCls: icon,
    
    
    autoLoad: {
    
    
    showMask: true,
    
    
    url: url,
    
    
    mode: 'iframe',
    
    
    maskMsg: 'Loading ' + url + '...'
    
    
    }
    
    
    });
    
    
    tabPanel.setActiveTab(tab);
    
    
    }//calling addtab
    
    
    
    <ext:MenuItem ID="TextMenuItem2" runat="server" Text="Member1">
    
    
    <Listeners>
    
    
    <Click Handler="addTab(#{TabPanel1}, 'member', 'member.aspx','house');" />
    
    
    </Listeners>
    
    
    </ext:MenuItem>
  2. #2

    RE: add icon to a Tab

    did u register the icon?
  3. #3

    RE: add icon to a Tab



    I didn't. Could you be please show me how
    Thanks so much
  4. #4

    RE: add icon to a Tab

    Hi all,

    can anybody post the link on how to register icons?
  5. #5

    RE: add icon to a Tab

    You can register an icon server-side with the following code.


    this.ScriptManager1.RegisterIcon(Icon.Add);
    Or just add the appropriate css class to your Page which links to the icon .png, which is all the .RegisterIcon Method does.


    You'll need to set the .iconCls property instead of .icon if you manually create the css class.


    Hope this helps.


    Geoffrey McGill
    Founder
  6. #6

    RE: add icon to a Tab

    Hi Geoffrey,

    Thanks again for your reply.
    I have written the following code, but was not successful. I use coolite toolkit version 0.8.2.
    I work on ASP.NET MVC.


    server-side code
    
    
    
    <script runat="server">
    
    
    
    
    protected void Page_Load(object sender, EventArgs e) 
        {
            if (!Ext.IsAjaxRequest) 
                {
                    this.ScriptManager1.RegisterIcon(Icon.ChartPie);
                }
        }
    
    
    
    
    </script>

    JavaScript Function
    
    
    
    <script type="text/javascript">
        function addTab(tabPanel, id, url,icon) {
            var tab = tabPanel.getComponent(id);
            if (!tab) {
                tab = tabPanel.add({ 
                        id: id, 
                        title: id,
                        closable: true,
                        iconCls: icon, 
                        autoLoad: {
                        showMask: true,
                        url: url,
                        mode:'iframe',
                        maskMsg: 'Loading ' + id + '...'
                        }
                });
    
    
            tab.on('activate', function() {
            var item = MenuPanel1.menu.items.get(id + "_item");
            if (item) {
                MenuPanel1.setSelection(item);
            }
            }, this);
        }
        tabPanel.setActiveTab(tab);
    }
    </script>
    View Port "West"
    <West Collapsible="true" Split="true">
    <ext:MenuPanel ID="MenuPanel1" runat="server" Height="300" Title="Menu" Width="185" Collapsed="false">
        <Menu ID="Menu1" runat="server">
            <Items>
            <ext:MenuItem ID="MarkupVsGrid_item" runat="server" Text="Inventory Vs MarkUp" Icon="ChartPie">
                <Listeners>
                    <Click Handler="addTab(#{TabPanel3}, 'InvVsMarkup', 'http://5qjx5j1/FICMID/Chart/ChartMarkUp/','ChartPie');" />
                    </Listeners>
            </ext:MenuItem>
            </Items>
        </Menu>
    </ext:MenuPanel> 
    </West>
  7. #7

    RE: add icon to a Tab

    Hi,
    You need to
    insert the word "icon-" (lowercase) before the name of the icon. See example:

    Ex: icon-application, icon-add, icon-cross, ..... icon-name_other_icons....

     function addTab(tabPanel, id, title, url, icone) {
                var tab = tabPanel.getComponent(id);
                var iconeTab = 'icon-' + icone.toLowerCase();     
                if (!tab) {
                    tab = tabPanel.add({
                        id: id,
                        title: title,
                        iconCls: iconeTab || 'icon-applicationdouble',
                        closable: true,                    
                        autoLoad: {
                            showMask: true,
                            url: url,
                            mode: 'iframe',
                            noCache: true,
                            color: '#E1E1E1',
                            maskMsg: 'Carregando ...'
                            
                        }
                    });
    
                }
                tabPanel.setActiveTab(tab);
            }
    Maia
    Coolite 0.8.2
  8. #8

    RE: add icon to a Tab

    Hi Maia,

    It worked perfectly fine.
    Thank you very much.

    mark it as solved.

Similar Threads

  1. [CLOSED] FireFox 13.0 and ext:TextField icon: icon untidy.
    By supera in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Jun 18, 2012, 5:21 PM
  2. Replies: 5
    Last Post: Aug 02, 2010, 8:44 AM
  3. Replies: 3
    Last Post: Jul 20, 2010, 7:48 PM
  4. Replies: 5
    Last Post: Mar 05, 2010, 3:15 PM
  5. Replies: 0
    Last Post: Jun 17, 2009, 6:36 PM

Posting Permissions