Results 1 to 9 of 9

Thread: [4.0.2] store.removeAll() does not perform view.all.clear()

    Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    59
    Vote Rating
    2
      0  

    Exclamation [4.0.2] store.removeAll() does not perform view.all.clear()

    Bug
    Ext.data.Store.removeAll() does not trigger Ext.view.AbstractView.all.clear() at the correct time. This causes immediate calls to Ext.data.Store.insert() to result in an indexing error.

    Environment
    OS: Windows 7 Professional SP1 x64
    ExtJS: 4.0.2
    Browsers:
    • Google Chrome 12.0.742.91
    • Firefox 4.0.1
    • Internet Explorer 9.0.8112.16421
    • Safari 5.0.5 (7533.21.1)
    • Opera 11.11 (Build 2109)


    Steps to reproduce:
    1. Run the code below:
      Code:
      Ext.onReady(function() {
      	var i = 0,
      		max;
      
      	Ext.define('MyModel', {
      		extend: 'Ext.data.Model',
      		fields: [
      			{
      				name: 'col1',
      				type: 'string'
      			},
      			{
      				name: 'col2',
      				type: 'string'
      			}
      		]
      	});
      
      	var data = [];
      
      	var store = Ext.create('Ext.data.Store', {
      		model: 'MyModel',
      		buffered: true
      	});
      	store.insert(0, data);
      
      	var columns = [
      		{
      			text: 'Col 1',
      			dataIndex: 'col1'
      		},
      		{
      			text: 'Col 2',
      			dataIndex: 'col2',
      			flex: 1
      		}
      	];
      
      	var selModel = Ext.create('Ext.selection.RowModel');
      
      	var grid = Ext.create('Ext.grid.Panel', {
      		width: 300,
      		height: 300,
      		renderTo: Ext.getBody().createChild(),
      		store: store,
      		columns: columns,
      		selModel: selModel
      	});
      
      	var insert = Ext.create('Ext.button.Button', {
      		text: 'insert',
      		renderTo: Ext.getBody().createChild()
      	});
      	insert.on('click', function() {
      		for (max = i + 3; i < max; i++) {
      			data.push(Ext.ModelManager.create({
      				col1: 'row' + i + '-col1',
      				col2: 'row' + i + '-col2'
      			}, 'MyModel'));
      		}
      //		grid.view.all.clear();
      		store.insert(0, data);
      	}, this);
      
      	var remove = Ext.create('Ext.button.Button', {
      		text: 'remove',
      		renderTo: Ext.getBody().createChild()
      	});
      	remove.on('click', function() {
      		store.removeAll();
      		console.log(grid.view.all.elements.length);
      	}, this);
      
      	var update = Ext.create('Ext.button.Button', {
      		text: 'update',
      		renderTo: Ext.getBody().createChild()
      	});
      	update.on('click', function() {
      		for (max = i + 3; i < max; i++) {
      			data.push(Ext.ModelManager.create({
      				col1: 'row' + i + '-col1',
      				col2: 'row' + i + '-col2'
      			}, 'MyModel'));
      		}
      		store.removeAll();
      //		grid.view.all.clear();
      		store.insert(0, data);
      	}, this);
      });
    2. Click "update". 3 records are added as expected.
    3. Click "update" again. 3 records are added as expected. However, an error occurs in Ext.view.AbstractView.updateIndexes().


    Clicking "insert", then "remove", then "insert" again achieves the same end result, without the error. Note the console output after "remove" indicates the view's elements are not removed.

    Also try clicking "insert", then "insert" again. The same error occurs.

    Error Messages by Browser:
    • Chrome: Uncaught TypeError: Cannot read property 'internalId' of undefined
    • Firefox: records[i] is undefined
    • IE: SCRIPT5007: Unable to get value of the property 'internalId': object is null or undefined
    • Safari: TypeError: Result of expression 'records[i]' [undefined] is not an object.
    • Opera: Uncaught exception: TypeError: Cannot convert 'records[i]' to object


    Workaround:
    Comment out grid.view.all.clear(); in the update click handler. This manually clears the view's elements before the store's insert, preventing the error.

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Vote Rating
    100
      0  

    Default

    grid.view.all.clean() wasnt working for me. I had to use destroy on all items of the panel.

  3. #3
    Ext JS Premium Member KimSchneider's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    68
    Vote Rating
    0
      0  

    Default

    +1 have the same issue which is really anoying
    Kim Schneider
    Lead Developer

    Server-Eye
    Alte Komannschule
    Komannstrae 7
    66571 Eppelborn
    Germany

    Email: kim.schneider@server-eye.de
    Homepage: www.server-eye.de

    Do you know our revolution in network- and servermonitoring?
    www.server-eye.de

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
      0  

    Default

    this has been a real pain for me as well.

  5. #5
    Sencha - Engineering Operations mike.estes's Avatar
    Join Date
    Mar 2011
    Location
    Redwood City, CA
    Posts
    221
    Vote Rating
    9
      0  

    Default

    looks like this was fixed in 4.0.5, I was able to reproduce in earlier versions but not in 4.0.5 or latest dev code

  6. #6
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
      0  

    Default

    oh great. I am using the gpl version for now. I guess I have to wait until the 4.1 release? Does anyone know how I can work around this? I am calling .removeAll() on a store right now and have issues when I call add() soon after.

    -Arun

  7. #7
    Ext JS Premium Member KimSchneider's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    68
    Vote Rating
    0
      0  

    Default

    Yes, fixed in 4.0.5. Thanks!

    @ddr: The workaround is to call grid.view.all.clear()
    Kim Schneider
    Lead Developer

    Server-Eye
    Alte Komannschule
    Komannstrae 7
    66571 Eppelborn
    Germany

    Email: kim.schneider@server-eye.de
    Homepage: www.server-eye.de

    Do you know our revolution in network- and servermonitoring?
    www.server-eye.de

  8. #8
    Sencha User
    Join Date
    Jan 2008
    Location
    Nice, France
    Posts
    43
    Vote Rating
    0
      0  

    Default

    Hello,
    I propose this workaround which works for me :
    Code:
    while (store.getCount(0) > 0)
     store.removeAt(0);
    Bye

  9. #9
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    1
      1  

    Default

    This issue still happening to me in version 4.2.0!!

    store.removeAll() will remove all the items in the store but the view still having the data it was showing...

    I went to the view under view.el.dom.childNodes and children still having the items.... I don't know what to do....

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
  •