1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    4
    Vote Rating
    2
    qx2005 is on a distinguished road

      2  

    Default [4.2.1.789] no reindex after insertion to a data.Store

    [4.2.1.789] no reindex after insertion to a data.Store


    We are having a case to insert a record manually to an Ext.data.Store for a grid panel. The calling method is Ext.data.Store.insert(index, records). The record gets inserted without a problem. However, when you click on any row below the newly inserted record, the one above the clicked row gets highlighted.

    We debugged into the code behind and found that each item in store.data.items has a property called "index". After insertion, this "index" property is not re-calculated in case the store is not sorted (store.requireSort == false).
    Even though Ext.4.1.3 does the same thing without re-indexing, it actually calls store.indexOf(record) in response to the click event, so there is no problem.
    However for Ext 4.2.1.789, it calls getAt(index) in response to the click event, so that the problem above occurs.

    The workaround below works for us, but we do not believe it is an ultimate fix:
    Code:
    Ext.override(Ext.data.Store, {
      insert: function(index, records) {
        var me = this;
        me.callParent(arguments);
    
        if (index >= 0 && records && records.length > 0 && !me.requireSort) {
          for (var i = index; i < me.getCount(); i++) {
            me.data.items[i].index = i;
          }
        }
      }
    });

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,913
    Vote Rating
    179
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    I'm not able to reproduce the issue in 4.1.3, 4.2, or 4.2.1.818 (latest Nightly) in Chrome using the test case below. Am I not setting up the test case quite right? Do you see the issue with the test case?

    Code:
    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        fields:['name', 'email', 'phone'],
        data:{'items':[
            { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
            { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
            { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
            { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    
    var grid = Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
            { text: 'Name',  dataIndex: 'name' },
            { text: 'Email', dataIndex: 'email', flex: 1 },
            { text: 'Phone', dataIndex: 'phone' }
        ],
        height: 200,
        width: 400,
        renderTo: Ext.getBody(),
        tbar: [{
            text: 'Insert'
            , handler: function () {
                grid.getStore().insert(2, { 'name': 'Insert',  "email":"inser@simpsons.com",  "phone":"555-222-1234" });
            }
        }]
    });

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    14
    Vote Rating
    1
    Decoy Deluxe is on a distinguished road

      0  

    Default Store reindex after insert

    Store reindex after insert


    I would expect the store in your test case to be indexed from 0-4 after insert but it is not.

    Try it here: http://jsfiddle.net/S5NK3/3/

Thread Participants: 2

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