1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    162
    Answers
    7
    Vote Rating
    2
    UbuntuPenguin is on a distinguished road

      0  

    Default Answered: Combobox works when I move my store

    Answered: Combobox works when I move my store


    Hello Everyone,
    I had a custom combobox class that used a store. I declared my store like so

    Code:
            ds = Ext.create('Ext.data.Store', {
                model: 'KesslerAdmin.model.LineItemType',
                proxy: {
                    type:'ajax',
                    url:'line_item_type/search_by_product_type.json',
                    reader:{
                        type:'json'
                    }
                }
            });
          Ext.define('KesslerAdmin.view.AwesomeCombobox', {
    This worked fine until I had another instance declared in another view by xtype.

    I was confounded for days wondering how my code broke overnight. Then I changed my combobox and moved my store into the initComponent declaration.

    Code:
    ...
    initComponent:function () {
            var me = this;
            var ds = Ext.create('Ext.data.Store', {
                model: 'KesslerAdmin.model.LineItemType',
                proxy: {
                    type:'ajax',
                    url:'line_item_type/search_by_product_type.json',
                    reader:{
                        type:'json'
                    }
                }
            });
            me.store = ds,
            Ext.applyIf(me, {
    ...
    After that my combobox which was declared twice by xtype in my application worked like a charm. My question is, what concept am I missing. Why would declaring a component by its xtype break the combobox. By the way, if I remember correctly, the error was 'Object <object> has no method read.

  2. When you put it in the definition, it gets shared across instances. For "primitive" types (strings, numbers, bools) it isn't a problem, however for objects it becomes apparent:

    Code:
    Ext.define('Foo', {
        bar: []
    });
    
    var a = new Foo();
    a.bar.push(1);
    var b = new Foo();
    console.log(b.bar[0]);

  3. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,828
    Answers
    453
    Vote Rating
    609
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    When you put it in the definition, it gets shared across instances. For "primitive" types (strings, numbers, bools) it isn't a problem, however for objects it becomes apparent:

    Code:
    Ext.define('Foo', {
        bar: []
    });
    
    var a = new Foo();
    a.bar.push(1);
    var b = new Foo();
    console.log(b.bar[0]);
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    162
    Answers
    7
    Vote Rating
    2
    UbuntuPenguin is on a distinguished road

      0  

    Default


    Thanks Evan. Just one more question, do you know why having the 'store' shared across instances would cause the 'Object <object> has no read method' error ?

Thread Participants: 1

Tags for this Thread

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