1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Montreal
    Posts
    48
    Vote Rating
    0
    JFFortierQc is on a distinguished road

      0  

    Default Answered: Accessing hasMany object localy not working?

    Answered: Accessing hasMany object localy not working?


    What am I doing wrong?
    In Sencha Touch 1, it was possible to call a Store like that this.tvProviders(); where tvProviders is the name in the hasMany properties. In Sencha Touch 1, that did return a tvProvidersStore object.
    Code:
    Ext.define("MyApp.model.configs.TvProviderList", {extend: "Ext.data.Model",
            configs: {
                hasMany: {model: 'MyApp.model.configs.TvProvider', name: 'tvProviders'}
            },
            
            constructor: function() {
                this.callParent(arguments);
                
                var tvpStore = this.tvProviders();
            }
        }
    );
    In Sencha Touch 2 I get this error : TypeError: 'undefined' is not a function (evaluating 'this.tvProviders()')
    Any idea how to solve that. I really need to access it locally. Can't load external data by Proxy. I want to be able to add TvProvider Class object in that like :
    var tvpStore = this.tvProviders();
    tvpStore.add(aTvProviderInstance);

  2. This is working for me:

    Code:
    Ext.define('Search', {
        extend : 'Ext.data.Model',
    
        config : {
            fields  : [
                'id',
                'query'
            ],
    
            hasMany : {
                model : 'Tweet',
                name  : 'tweets'
            }
        },
    
        constructor : function() {
            this.callParent(arguments);
    
            var store = this.tweets();
    
            console.log(store);
        }
    });
    
    Ext.define('Tweet', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                'id',
                'text',
                'from_user'
            ]
        }
    });
    
    Ext.application({
        name : 'Test',
    
        launch : function () {
    
            new Search({query: 'Sencha Touch'});
    
        }
    });

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This is working for me:

    Code:
    Ext.define('Search', {
        extend : 'Ext.data.Model',
    
        config : {
            fields  : [
                'id',
                'query'
            ],
    
            hasMany : {
                model : 'Tweet',
                name  : 'tweets'
            }
        },
    
        constructor : function() {
            this.callParent(arguments);
    
            var store = this.tweets();
    
            console.log(store);
        }
    });
    
    Ext.define('Tweet', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                'id',
                'text',
                'from_user'
            ]
        }
    });
    
    Ext.application({
        name : 'Test',
    
        launch : function () {
    
            new Search({query: 'Sencha Touch'});
    
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    11
    Vote Rating
    0
    ntkonstantinov is on a distinguished road

      0  

    Default


    I'm having a similar issue about this one. Let's say for example I want to add a collection of tweets, when instantiating the Search model. The problem I'm facing is that this collection is not stored in the data holder, but rather in the raw property.
    Code:
    var test = new Search({query: 'Sencha Touch', tweets: [{id: 'testId1', text: 'testText1', from_user: 'sampleUser1'}, {id: 'testId2', text: 'testText2', from_user: 'sampleUser2'}]});
    [COLOR=rgba(255, 255, 255, 0.699219)][/COLOR]
    Object
    
    
    
    undefined
    test
    [COLOR=rgba(255, 255, 255, 0.699219)][/COLOR]
    Object
    
    • _data: Object
    • data: Object
      • id: "ext-record-326"
      • query: "Sencha Touch"
      • __proto__: Object
    • id: "ext-record-326"
    • internalId: "ext-record-326"
    • modified: Object
    • phantom: true
    • raw: Object
      • query: "Sencha Touch"
      • tweets: Array (2)
      • __proto__: Object
    • stores: Array (0)
    • tweetsStore: Object
    • __proto__: Object
    • I want these tweets to be stored in the data property, because after that I'm calling the model.save() method, which uses exactly that data.
    • I tried the same logic, but done with stores and in that case the association is working fine.
    Thank you for the attention.



  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That is because the associated data (event if returned from a server call) is not attached to the data at all. It's on the store/model instance that is created from the association.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    11
    Vote Rating
    0
    ntkonstantinov is on a distinguished road

      0  

    Default


    Hmm. That's a little bit strange, because when I'm using a json object coming from a server(invoked before that with store.load() func) the results are different. I mean in the data field of the "A" class, I see the collection of "B" classes. And the association is A has many B. Why is that happening ? If I use a store, defined with models and associations the data is ok. But if I take the json result from server and hardcode it in the model's constructor or pass it as a parameter in Ext.create() function, the result is different ...

  7. #6
    Sencha User
    Join Date
    Oct 2011
    Location
    Montreal
    Posts
    48
    Vote Rating
    0
    JFFortierQc is on a distinguished road

      0  

    Default


    Ok
    Human mistake
    configs: {}
    instead of
    config: {}

    Don't tell anyone

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi