Search code examples
javascriptextjssencha-touchsencha-touch-2

Get title property in my tabpanel


i have a tabpanel in a view and many tabs in tabpanel, i want get the string of title in controller

my tabpanel code:

        {
            xtype: 'tabpanel',
            itemId: 'tabfirst',
            flex: 1,
            //activeItem: 1,
            tabBar: {
                layout: {
                    pack: 'center'
                }
            },
            items: [
                {
                    title: 'tab1',//---------i want get it's value tab1
                    xtype: 'list',
                    itemTpl: '{title}',
                    data: [
                        {title : 'title1'},
                        {title : 'title2'},
                        {title : 'title3'}
                    ]
                },
                {
                    title: 'tab2',
                    html: 'here second html2'
                }
            ]
        }

in controller launch function code

    var moneytab = Ext.ComponentQuery.query('.makemoney #tabfirst')[0];
    console.log(moneytab.getItems().......how can i get the value of title........);

the above getItems return a list of array in my chrome console

enter image description here

my title is in array1 in items.THX


Solution

  • You are not querying to the tab, but to the tabpanel itself. The items your are showing are the items of the tabpanel, not of the tab..

    {
        xtype: 'tabpanel',
        itemId: 'myTabPanel',
        flex: 1,
        tabBar: {
            layout: {
                pack: 'center'
            }
        },
        items: [
            {
                title: 'tab1',
                xtype: 'list',
                itemId: 'myFirstTab',
                itemTpl: '{title}',
                data: [
                    {title : 'title1'},
                    {title : 'title2'},
                    {title : 'title3'}
                ]
            },
            {
                title: 'tab2',
                html: 'here second html2'
            }
        ]
    }
    
    var tabPanel = Ext.ComponentQuery.query('#myTabPanel')[0],
        moneyTab = tabPanel.child('#myFirstTab');
    
    console.log(moneyTab.getTitle());
    moneyTab.setTitle('w00t');
    console.log(moneyTab.getTitle());