Interview Focused: What is XType in Ext JS?

1) Xtype is a symbolic name, an alias, given to a class. Nothing less, nothing more.
2) Its a smaller name generally given to a lengthy class name, like its easier to write USA, than United States of America.
3) Xtype instantiates a class lazily, remember lazy loading in java. that is create when needed, Ext.create instantiates eagerly thats even  if a call is not made to it. Thus xtype helps in saving memory.
4) Applications start up faster when you use xtype, as less objects are being created eagerly.
5) There can be more than one alias defined for a class name, just use a comma as delimiter.
6) More than one alias example :
  1. Ext.define('United.States.America',{
  2. extend:'some.continent'
  3. ,alias:['usa', 'america']
  4. });
7) All components inherit a method getXType(), which be can used to get xtype of an instantiated component.
  1. var someVariable = new Ext.form.TextField();
  2. alert(someVariable.<strong>getXType</strong>());
8) This property provides an array of the entire xtype chain for the component :  obj.xtypesChain  , if you need to perform some action based on the components xtype.
9) This method available on AbstractComponent will give you a true/false indicator if an object is an xtype, below code returns a boolean.
  1. obj.<strong>isXType</strong>('grid')
10) At last remember, every class or component is registered with Ext.ComponentManager class with a unique string key and a reference to that class, which is then referred to as an xtype. example
  1. items: [{
  2. xtype : 'panel',
  3. autoWidth : true,
  4. fieldLabel : 'Name'
  5. }]

Comments

Popular posts from this blog

Java Interview : Threads

Spring Framework Interview Notes : Part Two Wiring

Card Dealer In Java in Less than 5 minutes