PDA

View Full Version : Filtering a store, then clearing the filter does not return the store to original



d5chris
16 Mar 2011, 8:55 PM
Hi all,
I have a store which i set a filter on. I then clear the filter, but it does not return the store's number of items to the original length before the filter. Here's a snippet from the chrome console to see what i'm trying below. What have i done wrong? I would have thought upon clearing the filter i'd be back to my original 500 records in the store.


app.stores.vod.data.items.length
500
app.stores.vod.filter('type','SHOWS')
undefined
app.stores.vod.data.items.length
362
app.stores.vod.clearFilter()
undefined
app.stores.vod.data.items.length
35

Thanks

d5chris
16 Mar 2011, 9:19 PM
It looks like sencha is setting the 'snapshot' field on the store before i've completed adding all the records to it, so that when i filter and then clear the filter, it restores to the snapshot which was taken too early. I thought it only set the snapshot upon filtering? I'm not doing any filters beforehand. odd.

d5chris
16 Mar 2011, 9:31 PM
I'm doing multiple loads on this particular store, with 'addRecords' set to true so that it'll be a cumulative total of multiple ajax calls. It seems that somewhere while loading, it saves a 'snapshot' too early. But i can't figure out why, because looking in the sencha code it only saves snapshots upon filtering, which i'm not doing at that point yet...

SimonFlack
17 Mar 2011, 4:44 AM
I posted a bug report on this a while ago. Feel free to update it.

http://www.sencha.com/forum/showthread.php?120884-OPEN-719-(1.0.1a)-Store.snapshot-contains-corrupt-data.&highlight=corrupt

Oyvin posted a temp fix.


someStore.on('load', function (store) {
store.snapshot = store.data;
});

d5chris
17 Mar 2011, 1:19 PM
Thanks simon, i'll use that fix.

Sh1n1
17 Mar 2011, 11:25 PM
What if you try to set filterOnLoad: false?