taher
taher

Reputation: 549

Add grid dynamically to specific tab in tabpanel

How can i add grid dynamically to specific tab in tabpanel?
My tabPanel:

var tabs = Ext.create('Ext.tab.Panel', {
            region: 'center', // a center region is ALWAYS required for border layout
            deferredRender: false,
            activeTab: 0,     // first tab initially active
            items: [{
                title: 'grid',
                autoScroll: true
            }, {
                title: 'Center Panel',
                autoScroll: true
            }]
        });

I want to add grid dynamically to grid tab in tabs!.I can get grid tab with tabs.getComponent(0) but i don't know how can i add grid to it!
In my app i have button that when user clicked it i add grid to grid tab in tabPanel.

Upvotes: 0

Views: 863

Answers (1)

taher
taher

Reputation: 549

For adding Grid to specific tab as content i do this trick!:

tabs.remove(tabs.getComponent(0));
    tabs.insert(0,grid);
    tabs.getComponent(0).setTitle("grid");
    tabs.setActiveTab(0);
    tabs.doLayout();

I only remove specific tab and insert new tab to its position and change title of new tab to previous removed tab and set active new tab!

Upvotes: 1

Related Questions