Results 1 to 6 of 6

Thread: Using alias or xtype?

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Vote Rating
    2
      0  

    Default 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
    } );

  2. #2
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    22
    Vote Rating
    0
      0  

    Default

    +1.

    Am curious also.

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    628
    Vote Rating
    40
      0  

    Default

    xtype is the newer way and of course preferred...I think

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      1  

    Default

    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

    Code:
    alias : 'widget.mycomponent'
    that is the same as

    Code:
    xtype : 'mycomponent'
    IF you have:

    Code:
    alias : 'store.mystore'
    You can then create the store like:

    Code:
    store : {
        type : 'mystore'
    }
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Vote Rating
    2
      0  

    Default

    Makes sense.
    Also, should that last piece of code be:
    Code:
    store:
    {
     xtype: 'mystore'
    }
    ?

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    No, just type. xtype is only for components
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •