PDA

View Full Version : Using alias or xtype?



michael.parrott
17 Jul 2012, 11:49 AM
I was wondering what the different between defining the alias of your class or the xtype of your class was. For a view, you can put alias: 'widget.home' or xtype: 'home' at the top and later on reference the view using the xtype of 'home'. What's the point of having both?


Ext.define( 'App.view.Home',
{
extend: 'Ext.Container',
alias: 'widget.home',
xtype: 'home' //accomplishes the same as above
} );

salorob
18 Jul 2012, 6:26 AM
+1.

Am curious also.

estesbubba
18 Jul 2012, 6:42 AM
xtype is the newer way and of course preferred...I think

mitchellsimoens
19 Jul 2012, 4:21 AM
Using xtype is just simpler and easier for people to get started using it. It actually sets up the alias.

To understand what they are, the alias is a two part value separated by a single period:

[alias type].[type]

alias type is is the type of alias (that's not too descriptive is it? :) ). Values can be like widget (components), store, proxy, reader, etc.

type is the shorthand type of the class. This is the xtype for components or the widget alias type.

So if you have


alias : 'widget.mycomponent'

that is the same as


xtype : 'mycomponent'

IF you have:


alias : 'store.mystore'

You can then create the store like:


store : {
type : 'mystore'
}

michael.parrott
19 Jul 2012, 10:07 AM
Makes sense.
Also, should that last piece of code be:


store:
{
xtype: 'mystore'
}
?

mitchellsimoens
19 Jul 2012, 10:34 AM
No, just type. xtype is only for components