-
11 Jan 2011 2:53 AM #1
[TOUCH-428] Store.snapshot contains corrupt data.
[TOUCH-428] Store.snapshot contains corrupt data.
Sencha Touch version tested:
- 1.0.1a
- only default ext-all.css
Description:- Store snapshot is corrupt after changing a proxies data source and reloading the store.
- Similar problems also happen if using paging. Clearing the filter causes the first page to be reloaded into the store from the snapshot.
Test Case:Code:clearFilter : function(suppressEvent) { this.filters.clear(); if (this.isFiltered()) { this.data = this.snapshot.clone(); delete this.snapshot; if (suppressEvent !== true) { this.fireEvent('datachanged', this); } } },
Code:Ext.regModel('SomeModel', {fields: ['name']}); var myProxy = new Ext.data.MemoryProxy({ type: 'memory', reader: { type: 'json', root: 'root' } }); var data1 = { root: [ {name: 'One'}, {name: 'Two'}, ] }; var data2 = { root: [ {name: 'Cat'}, {name: 'Dog'}, {name: 'Fish'} ] }; var myStore = new Ext.data.Store({ model: 'SomeModel', proxy: myProxy }); //Setup Ext.setup({ icon: 'icon.png', glossOnIcon: false, onReady: function() { var myList = new Ext.List({ id: 'theList', fullscreen: true, itemTpl : '{name}', store: myStore }); } });
Steps to reproduce the problem: (In Console)- Ext.getCmp('theList').store.proxy.data = data1
- Ext.getCmp('theList').store.load()
- Ext.getCmp('theList').store.proxy.data = data2
- Ext.getCmp('theList').store.load()
- Ext.getCmp('theList').store.filter('name', 'Fish')
- Ext.getCmp('theList').store.clearFilter()
The result that was expected:- One, Two ( After first load() )
- Cat, Dog, Fish ( After second load() )
- Fish ( After filtering)
- Cat, Dog, Fish ( After clearFilter())
The result that occurs instead:- One, Two ( After first load() )
- Cat, Dog, Fish ( After second load() )
- Fish ( After filtering)
- One, Two ( After clearFilter() )
Screenshot or Video:
Possible fix:- Update the Store's snapshot when proxies data is changed. For example if the application changes the "url" of a RESTProxy and then reloads the store the snapshot shoult contain this new data and not the data from the original loaded data.
Last edited by SimonFlack; 11 Jan 2011 at 3:02 AM. Reason: Added sencha version
-
24 Feb 2011 1:46 PM #2
I can verify that adding:
someStore.on('load', function (store) {
store.snapshot = store.data;
});
makes filtering/clearing work as desired.
--
Oyvin
-
17 Mar 2011 1:18 PM #3
Me too having a problem with this bug:
http://www.sencha.com/forum/showthre...460#post581460
Please fix.
Our team also has a paid support account under the name 'pdiemert' FWIW.
-
10 Apr 2011 8:05 AM #4
The bug is still present in 1.1
For some reason oyvinht's fix didn't work for me so I added the following code to the loadRecords function.
Code:this.data = this.snapshot.clone(); delete this.snapshot; this.fireEvent('datachanged', this);
-
13 Jun 2011 1:13 PM #5
Very frustrating problem. Seems like a flaw in some of the rather basic core functionality of a store.
-
13 Jun 2011 5:36 PM #6
This is a serious bug that is known for several months:
http://www.sencha.com/forum/showthre...hen-using-load
http://www.sencha.com/forum/showthre...Store.loadData
http://www.sencha.com/blog/ext-js-4-...released#19311
-
20 Aug 2011 11:03 AM #7
Override to Ext.data.Store.loadRecords()
Override to Ext.data.Store.loadRecords()
We added this override (the line below the big starred comment) to delete the snapshot. Not thoroughly tested by any means but seems to solve the issues we were having. Any feedback?
Bizarre that this has not been fixed. Thanks - ATM
Code:Ext.override(Ext.data.Store, { loadRecords: function(records, add) { if (!add) { this.data.clear(); } this.data.addAll(records); // *************************************************************** // As of Touch 1.1 the snapshot is not updated/cleared properly on data load. // *************************************************************** if (this.snapshot) delete this.snapshot; for (var i = 0, length = records.length; i < length; i++) { records[i].needsAdd = false; records[i].join(this); } this.suspendEvents(); if (this.filterOnLoad && !this.remoteFilter) { this.filter(); } if (this.sortOnLoad && !this.remoteSort) { this.sort(); } this.resumeEvents(); this.fireEvent('datachanged', this, records); } });
-
26 Aug 2011 8:08 PM #8
store snapshot has wrong data
store snapshot has wrong data
I am reloading the store by changing its proxies url and then calling load. Now although store.data has the correct data, store.snapshot.data has the wrong data.
-
29 Aug 2011 7:26 AM #9
I've modified this thread to reflect the correct bug id
-
18 Oct 2011 12:39 AM #10
I have the same problem.
The override specified above fixes it though.
You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
Similar Threads
-
Snapshot in Store
By harsha_velicheti in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 6 Feb 2012, 8:32 AM -
[OPEN] [TOUCH-428] Ext.data.Store loadData does not clear / remove snapshot
By buz in forum Sencha Touch 1.x: BugsReplies: 6Last Post: 26 Aug 2011, 3:47 PM -
Grid Store snapshot
By taxidriver in forum Ext 3.x: Help & DiscussionReplies: 6Last Post: 11 Jan 2011, 4:40 AM -
[FIXED-719] Ext.store.groupBy('field') not firing 'groupchange' event
By sdesalas in forum Ext 3.x: BugsReplies: 1Last Post: 12 Mar 2010, 4:17 PM -
[2.0b1][CLOSED] Ext.data.Store.insert misses to update snapshot
By andrei.neculau in forum Ext 2.x: BugsReplies: 6Last Post: 22 Sep 2009, 11:15 PM


Reply With Quote