-
17 Jul 2012 11:49 AM #1
Using alias or xtype?
Using alias or xtype?
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?
Code:Ext.define( 'App.view.Home', { extend: 'Ext.Container', alias: 'widget.home', xtype: 'home' //accomplishes the same as above } );
-
18 Jul 2012 6:26 AM #2
-
18 Jul 2012 6:42 AM #3
xtype is the newer way and of course preferred...I think
-
19 Jul 2012 4:21 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
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
that is the same asCode:alias : 'widget.mycomponent'
IF you have:Code:xtype : 'mycomponent'
You can then create the store like:Code:alias : 'store.mystore'
Code:store : { type : 'mystore' }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Jul 2012 10:07 AM #5
Makes sense.
Also, should that last piece of code be:
?Code:store: { xtype: 'mystore' }
-
19 Jul 2012 10:34 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
No, just type. xtype is only for components
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote