Results 1 to 3 of 3

Thread: [] no reindex after insertion to a data.Store

  1. #1
    Sencha User
    Join Date
    Apr 2011

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

    We are having a case to insert a record manually to an for a grid panel. The calling method is, 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 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, 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:
    Ext.override(, {
      insert: function(index, records) {
        var me = this;
        if (index >= 0 && records && records.length > 0 && !me.requireSort) {
          for (var i = index; i < me.getCount(); i++) {
  [i].index = i;

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Boise, ID


    I'm not able to reproduce the issue in 4.1.3, 4.2, or (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?

    Ext.create('', {
        fields:['name', 'email', 'phone'],
            { 'name': 'Lisa',  "email":"[email protected]",  "phone":"555-111-1224"  },
            { 'name': 'Bart',  "email":"[email protected]",  "phone":"555-222-1234" },
            { 'name': 'Homer', "email":"[email protected]",  "phone":"555-222-1244"  },
            { 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254"  }
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
    var grid = Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        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":"[email protected]",  "phone":"555-222-1234" });

  3. #3

    Default 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:

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts