-
10 Jun 2011 2:26 PM #1
[4.0.2] store.removeAll() does not perform view.all.clear()
[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:- 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); }); - Click "update". 3 records are added as expected.
- 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.
-
29 Jul 2011 5:48 AM #2
grid.view.all.clean() wasnt working for me. I had to use destroy on all items of the panel.
-
17 Aug 2011 4:10 AM #3
+1 have the same issue which is really anoying
Kim Schneider
Lead Developer
Server-Eye
Alte Koßmannschule
Koßmannstraße 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
-
25 Aug 2011 12:32 PM #4
-
25 Aug 2011 2:28 PM #5
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
-
25 Aug 2011 2:55 PM #6
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
-
25 Aug 2011 11:21 PM #7
Yes, fixed in 4.0.5. Thanks!
@ddr: The workaround is to call grid.view.all.clear()Kim Schneider
Lead Developer
Server-Eye
Alte Koßmannschule
Koßmannstraße 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
-
22 Sep 2011 2:00 AM #8
Hello,
I propose this workaround which works for me :
ByeCode:while (store.getCount(0) > 0) store.removeAt(0);
-
25 Apr 2013 4:29 AM #9
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....
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.


Reply With Quote