How to get the xtype of an instantiated component?

Grant Zhu picture Grant Zhu · Feb 20, 2012 · Viewed 9.9k times · Source

Suppose I have an component's instance but I don't know what it is. Is there a convenient way to get the xtype of this component?

Answer

Chau picture Chau · Feb 20, 2012

According to the API all components (all types of Ext JS objects with an xtype I guess) inherits a method getXType(), which you can use like in the following:

var t = new Ext.form.TextField();
alert(t.getXType());  // alerts 'textfield'