Results 1 to 3 of 3

Thread: Viewport, ref, alias, xtype confusion

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
      0  

    Default Viewport, ref, alias, xtype confusion


    I've been trying to figure out the twitter example and I am having trouble understanding how some of the pieces fit together. Here are my questions:

    From Search.js:

    Code:
        refs: [
            {
                ref       : 'main',
                selector  : 'mainview',
                xtype     : 'mainview',
                autoCreate: true
            },
    * The selector and xtype are not explicitly defined in the Main.js container (aka. viewport). How is the selector in refs or xtype in refs used to identify the 'Twitter.view.Main' container?

    * Why are selector and xtype both specified? Isn't only one of them needed?

    * Is the alias property (widgets) of Containers used by refs in any way?

    * If autoCreateViewport is used in the app definition, will autoCreate automatically put the mainview panel in the viewport?


    Thanks,

    Bruce


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

    Default

    The selector is used with ComponentQuery to get the reference of that selector and cache it. The ref is for the name or the getter method that is automatically created, first character will be capitalized (in your example, 'main' will be transformed into 'getMain'). selector is ComponentQuery, if you have autoCreate set to true and there is no instance found, an instance will be created based on the xtype.

    The alias property is definitely used. alias is a two part string, first is the type of alias and the second is the xtype which is used for ComponentQuery and instantiation.

    autoCreate will only create an instance if there is not already an instance that matches the selector and if you execute the getter method that is created. So autoCreateViewport will create the Viewport class but in your controller you would have to call the getter method before the autoCreateViewport is executed to have a problem which isn't possible currently.
    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

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    18
    Vote Rating
    0
      0  

    Default

    How is the xtype: mainview in refs used to identify the 'Twitter.view.Main' container?
    this quest is still not answered yet, can you help us please ?
    best regards !

Posting Permissions

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