Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    17
    Vote Rating
    0
    cs0ip is on a distinguished road

      0  

    Default [4.1.1] Grid removeAt error

    [4.1.1] Grid removeAt error


    The test application:
    Code:
    Ext.onReady(function() {
      Ext.create('Ext.container.Viewport', {
        layout: 'border',
        items: [
          {
            region: 'center',
            xtype: 'grid',
            id: 'grid',
            store: Ext.create('Ext.data.Store', {
              fields: [
                {name: 'id', convert: null, defaultValue: undefined},
                {name: 'title', convert: null, defaultValue: undefined}
              ]
            }),
            columns: [
              {
                text: 'ID',
                dataIndex: 'id'
              },
              {
                text: 'Title',
                dataIndex: 'title'
              }
            ]
          },
          {
            region: 'north',
            xtype: 'buttongroup',
            items: [
              {
                text: 'fill grid',
                handler: function () {
                  var grid = Ext.getCmp('grid'), store = grid.getStore();
                  for (var i = 0; i <= 99; i++)
                    store.add({id: i, title: 'title' + i});
                }
              },
              {
                text: 'del rows',
                handler: function () {
                  var grid = Ext.getCmp('grid'), store = grid.getStore();
                  //store.suspendEvents(true);
                  for (var i = 99; i >= 25; i--)
                    store.removeAt(25);
                  //store.resumeEvents();
                }
              }
            ]
          }
        ]
      });
    });
    1) click "fill grid"
    2) click "del rows"
    3) no error

    Now, uncomment "store.suspendEvents(true);" and "store.resumeEvents();"

    1) reload page
    2) click "fill grid"
    3) click "del rows"
    4) error "TypeError: records[i] is undefined"

    -----
    firefox 18.0.1

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,925
    Vote Rating
    632
    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


    This is resolved in 4.2.0.

    Also, it's fairly poor practice to do this. You would be better to just suspend the events without catching them and refresh the view.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1