Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1648 in a recent build.
  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default PR4 Store insert method ignoring index

    PR4 Store insert method ignoring index


    I'm running into a strange problem with PR4 that didn't exist in PR3. The store.insert method is ignoring the index and adding the record to the bottom of the list. The store is loaded using the ajax proxy.

    My guess is that the insert is being performed before the store is loaded, but that should not be the case when called after the load event has fired.

    Code:
    		store.on({'load': function(store, records, successflag, oper) {
    				
    				// Remove any previously added optional labels
    				if (store.getAt(0).data.optional === true) {
    					store.removeAt(0);
    				}
    				
    				// If a label is passed, add it
    				if (label) {
    					store.insert(0, [{name: label, optional: true}]);
    					commList.down('list').select(0);
    				}
    			},
    			scope: this
    		});

  2. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    Moved to bug forums. Thanks.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    With the following test case on our latest code branch, the result is correctly

    Code:
            Ext.define('MyModel', {
                extend: 'Ext.data.Model',
    
                config: {
                    fields: [
                        'field1'
                    ],
    
                    proxy: {
                        type: 'ajax',
                        url: 'read.json',
                        reader: {
                            type: 'json',
                            rootProperty: 'results'
                        }
                    }
                }
            });
    
            Ext.setup({
                onReady: function() {
                    var store = Ext.create('Ext.data.Store', {
                        model: 'MyModel'
                    });
    
                    var dataview = Ext.create('Ext.DataView', {
                        store: store,
                        fullscreen: true,
                        itemTpl: 'Field1: {field1}'
                    });
    
                    store.on({
                        load: function(store, records, successflag, oper) {
                            store.insert(0, [{field1: 'Should be first'}]);
                        },
                        scope: this
                    });
    
                    store.load();
                }
            });
    I'm sending back the following test json:

    Code:
    {
        "success": true,
        "results": [
            {
                "field1": "blaat1"
            },
            {
                "field1": "blaat2"
            },
            {
                "field1": "blaat3"
            }
        ]
    }
    What I suspect is that you have a sorter active on your Store. In the new data package, the collection is always up to date in terms of sorting. This means that if you insert a record at index 0, but the sorting would cause the item to be somewhere else in the list, it would ignore your index 0 and instead move it to the right location based on the sorter.

    Could you please confirm if this could be the case? If so, I'll reopen this ticket. In the meantime I'm closing this ticket as I cannot reproduce in the latest code base.

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default


    I apologize. I did have a sorter that caused the problem.

    However, the sorter was sorting on a field that did not exist in the returned json or the model used by the store. For some reason, this still affected the sort order.

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Ok, that sounds like something that could be improved. I guess when the sorter executes and the value is always undefined, it still pushes it to the end of the list, which actually doesn't sound completely unreasonable but might not be expected behavior.

    In any case, it sounds like that sorter shouldn't have been there if the field it was sorting on didn't actually exist Glad it fixed your issue.

Thread Participants: 2

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..."