PDA

View Full Version : Ext.getCmp not working for extended tab panel



hirendave
21 Mar 2011, 5:28 AM
Hello,

I want to extend tab panel and add more functions to it. As of now my code looks like below.


Ext.ns("Applications.CustomTabs");

Applications.CustomTabs.Tabs = Ext.extend(Ext.TabPanel, {
initComponent : function() {
var config = {
id : 'applications_tab_panel',
margins : '3 3 3 3',
defaults: {
xtype : 'panel'
},
activeTab : 0,
items : [{title:'Home']}]
};
Ext.apply(this, config);
Ext.apply(this.initialConfig, config);
Applications.CustomTabs.Tabs.superclass.initComponent.apply(this);
}
});

I am not able to get this tab panel using Ext.getCmp("applications_tab_panel") .

Am I missing something here? Please advice.

Thanks,

walldorff
21 Mar 2011, 5:45 AM
http://www.sencha.com/learn/Manual:Component:Extending_Ext_Components

hirendave
21 Mar 2011, 5:58 AM
Thanks for pointing out to the document. I have followed all the guidelines for extending tab panel . Only thing missing was onRender. But still its not working for me.

walldorff
21 Mar 2011, 6:36 AM
var myTabs = new Applications.CustomTabs.Tabs(); isn't working?

mitchellsimoens
21 Mar 2011, 8:02 AM
using getCmp other than for debugging is bad practice
Do you need the id inside the initComponent? Why not just specify it as a config?

hirendave
21 Mar 2011, 9:59 AM
I want to add more tabs dynamically that's why I was using Ext.getCmp() to get component.

hirendave
21 Mar 2011, 10:04 AM
walldorff code you mentioned is working, even i can see tab panel rendered but i want to add more tabs dynamically.

walldorff
22 Mar 2011, 7:10 AM
i can see tab panel rendered but i want to add more tabs dynamically.
Ext.TabPanel has an add() method. Have a look and see if you can incorporate that in your extension.