Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Tab of TabPanel by id or itemId

Tags:

extjs

extjs4

I have a TabPanel in my View with Tabs. How can I get the instance of a Tab in this Panel and which property should be set id or itemId?

Thanks

openProjectMetaTab: function(project) {
    var tabPanel = this.getTab();
    console.log(tabPanel);
    var mpItemId = 'project-metaTab-' + project.get('id')
    console.log('#'+mpItemId);
    var metaPanel = tabPanel.getComponent(mpItemId);
    console.log(metaPanel);
    if(!metaPanel) {
        tabPanel.add({
            title: project.get('title'),
            closable: true,
            items: [
                {
                    xtype: 'projectMetaForm',
                    itemId: mpItemId,
                },
            ],
        }).show();
    }
}
like image 339
Gerrit Avatar asked Jan 27 '26 11:01

Gerrit


1 Answers

I would recommend using itemId because that way you don't have to worry about global id property conflicts. Per the documentation:

"Since itemId's are an index to the container's internal MixedCollection, the itemId is scoped locally to the container"

You can then use Ext.container.Container.getComponent to get your tabs.

Here is an example from the posters updated question:

openProjectMetaTab: function(project) {
    var tabPanel = this.getTab();
    console.log(tabPanel);
    var mpItemId = 'project-metaTab-' + project.get('id')
    console.log('#'+mpItemId);
    var metaPanel = tabPanel.getComponent(mpItemId);
    console.log(metaPanel);
    if(!metaPanel) {
        tabPanel.add({
            title: project.get('title'),
            closable: true,
            xtype: 'projectMetaForm',
            itemId: mpItemId
        }).show();
    }
}
like image 94
Reimius Avatar answered Jan 30 '26 06:01

Reimius