3
votes

I am using Ext.getCmp for finding one extjs component in tab panel. some times it is not working an returning undefined.

var currComp = Ext.getCmp('myId'); //Id is generated by me on creation

Is any other method exists? to find one Component if i know its id?

1
That's pretty much the way to find a component that has been rendered. If sometimes it is not working, it is probably that the call to this line is made too early (before the component is rendered. To solve this issue, it will help if you show how your view is created (with myId) and when do you call this Ext.getCmp.Izhaki

1 Answers

5
votes

If you know the parent control then getComponent method can be used.

getComponent - Examines this container's items property and gets a direct child component of this container.

 var compont = parentControl.getComponent('yourId');

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.container.AbstractContainer-method-getComponent

Try to set the itemId also when creating.