1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    43
    Vote Rating
    0
    Northie is on a distinguished road

      0  

    Default What are refs?

    What are refs?


    Looking through some of the more advanced MVC examples I see refs, eg

    Code:
        refs: [{
            ref: 'feedShow',
            selector: 'feedshow'
        }, {
        	ref: 'viewer',
        	selector: 'viewer'
        }, {
        	ref: 'articlePreview',
        	selector: 'articlepreview'
        }, {
            ref: 'articleTab',
            xtype: 'articlepreview',
            closable: true,
            forceCreate: true,
            selector: 'articlepreview'
        }],
    what are they?
    how do i use them?
    are they documented? If so, please tell me where!

  2. #2
    Sencha User littletree's Avatar
    Join Date
    Jun 2011
    Location
    USA
    Posts
    17
    Vote Rating
    0
    littletree is on a distinguished road

      0  

    Default


    They are documented under Ext.app.Controller, and here's a link to boot: http://docs.sencha.com/ext-js/4-0/#/...app.Controller.

    Scroll down the page a bit, and it will tell you all you need to know. Under the heading: "Using Refs". I haven't used them myself, but it looks promising.

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    42
    Vote Rating
    0
    elnaz is on a distinguished road

      0  

    Default


    You can add reference to any views in any controller.


    refs: [
    {
    ref : 'myGrid',
    selector: 'myGrid'
    }
    ]


    Here selector is the type of the component. This use can set with alias for views. For Example.


    Ext.define('myApp.myGrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.myGrid',

    initComponent: function () {
    this.callParent(arguments);
    }
    });


    ExtJs MVC has something called component query. This will be used to get reference of particular type of component.

    ref creates a function with name specified there and you can use that function to get reference of that particular component.

    You will get reference of myGrid by following code inside controller.

    var myGrid = this.getMyGrid();

    Remember here that it will not create new instance of grid. It will give a reference to an existing instance. If no instance is available it will return null.

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    68
    Vote Rating
    -1
    Siriru is an unknown quantity at this point

      0  

    Default


    And if many instances of the same view exist ? How to retrieve the right instance ?

  5. #5
    Sencha User
    Join Date
    Sep 2008
    Posts
    43
    Vote Rating
    0
    Northie is on a distinguished road

      0  

    Default


    Thanks all, this is looking really quite interesting. Subtle, but with huge potential/power

    Quote Originally Posted by Siriru View Post
    And if many instances of the same view exist ? How to retrieve the right instance ?
    Looking at the link to the documentation posted previously, the answer to this is that it returns the first matched element. To retrieve the desired instance use a more specific query...may be use an id? That's the way I'm going to be going

  6. #6
    Sencha User
    Join Date
    Apr 2011
    Posts
    68
    Vote Rating
    -1
    Siriru is an unknown quantity at this point

      0  

    Default


    Yes for the IDs, that's the way I use, but, if the number of instances depends on the database ? That's my problem : in my application I have a window for each user of the database, and it's the same view. I don't know how to retrieve the right instance (instance which calls an action).

  7. #7
    Ext JS Premium Member
    Join Date
    Feb 2010
    Posts
    28
    Vote Rating
    0
    jlindbergh is on a distinguished road

      0  

    Default


    Set a property user: "aUser" on the view when you create the view instance. Then do a query like databaseview[user=aUser] to get the correct instance?

  8. #8
    Sencha User
    Join Date
    Apr 2011
    Posts
    68
    Vote Rating
    -1
    Siriru is an unknown quantity at this point

      0  

    Default


    And I need one query for each user or I can set a generic query ?

  9. #9
    Ext JS Premium Member
    Join Date
    Feb 2010
    Posts
    28
    Vote Rating
    0
    jlindbergh is on a distinguished road

      0  

    Default


    I don't think that's possible using refs since they only act on the first matching component.
    Depending on where you catch the events from your different user-views, you can do a Ext.ComponentQuery.query() for all your user-views and look through that array for the window having the correct user property set.

  10. #10
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    474
    Vote Rating
    1
    johnnywengluu is on a distinguished road

      0  

    Default


    I don't quite get the purpose of refs[]. Why not just use ComponentQuery?

    More powerful and you don't need to have the unnecessary middle man. If it's because you wanna reuse the selector, you could just set it in a variable and reuse it.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar