-
3 Jan 2011 10:41 AM #1
Local Storage - store.remove() doesn't sync Local Store
Local Storage - store.remove() doesn't sync Local Store
When using a local storage proxy and removing a record the actual record gets removed from the store but upon sync() doesn't truly get removed from local storage. When a user refreshes their screen the removed record still exist.
Any ideas as to if this is a bug with Sencha Touch 1.0.1 or if I just have an issue with my code listed below? If a bug, will it be fixed with release of 1.0.2? any help is greatly appreciated.
PHP Code:Ext.regModel('MusicModel', {
fields: [{
name: 'name',
type: 'string'
}, {
name: 'path',
type: 'string'
}]
});
Ext.regStore("FavoritesStore", {
model: 'MusicModel',
sorters: 'name',
getGroupString: function(record){
return record.get('name')[0];
},
proxy: {
type: 'localstorage',
id: 'favorites-store-proxy',
proxy: {
idProperty: 'name'
}
},
autoLoad: true
});
// This is the function that is then called that passes in a valid record to remove:
removeFromFavorites: function(record){
var favorites = Ext.StoreMgr.get('FavoritesStore');
var r = favorites.findRecord('name',record.data.name);
favorites.remove(r);
favorites.sync();
}
-
15 Jan 2011 2:32 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
I'm going to bump this because I am getting the same problem. I have also found these other two threads that haven't been solved either:
http://www.sencha.com/forum/showthre...storage+remove
http://www.sencha.com/forum/showthre...storage+removeMitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
17 Jan 2011 10:15 PM #3
I'm working with version 1.01a. I have worked with localstorage it seems add and remove is working for me, some time i came across a problem but i couldn't able to recreate it
Below mention code works for me, let me know if any problem occurs
Code:Ext.setup({ onReady: function() { Ext.regModel('Contact', { fields: ['email'], proxy:{ type:'localstorage', id :'contact' } }); var contactStore = new Ext.data.Store({ model:'Contact', getGroupString : function(record) { return record.get('email')[0]; }, autoLoad:true }); var mainPanel = new Ext.Panel ({ fullscreen:true, scroll:false, dockedItems:[{ xtype:'toolbar', items:[{text :'Disclosure to Remove'},{xtype:'spacer'},{ text:'Add to Local Storage', handler:function(){ Ext.Msg.prompt("Welcome!", "Enter Email", function(stat,val){ if(stat == "ok"){ if(contactStore.findExact('email',val) == -1){ contactStore.add({email : val}); contactStore.sync(); } } }); } }] }], items:[{ xtype:'list', fullscreen: true, itemTpl : '{email}', onItemDisclosure: { handler: function(record, btn, index) { contactStore.remove(contactStore.findRecord('email',record.get('email'))); contactStore.sync(); } }, grouped : true, indexBar: false, store: contactStore }] }); } });
-
15 Feb 2011 10:25 AM #4
I am also having this problem. Adding works fine, but removing is not syncing...
-
20 Feb 2011 11:22 PM #5
It works for me if I add a field called "id" of type "int" to the model. Sencha Touch will populate the field. It seems, from having a quick look at the code, that Sencha Touch uses this field to identify the instance of the record that it must delete from the store.
-
21 Feb 2011 5:01 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Ok, we can close this thread as it's working in the last couple versions now.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Feb 2011 9:13 AM #7
Yep this works for me now. The id field was the key. Thanks for the response!
-
12 Apr 2011 12:08 AM #8
Still happening to me in 1.1. I tried the "id" fix chummy suggested and it worked. (didn't bother making it of type int).
-
12 Apr 2011 5:40 AM #9Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
13 Apr 2011 7:31 AM #10
Yup. You'll probably find you need to clear your LocalStore.
Code:// Set up local user state model template User.template = Ext.regModel('User', { fields: [ 'id', // DONT TOUCH // User identity 'user_id', 'secret', // Personal info 'firstName', 'lastName', 'email', 'website', 'portrait_url', 'twitter_screen_name' ] }); // Proxies User.remoteProxy = new Ext.data.AjaxProxy({ model: 'User', url: User.proxyURL, reader: { type: 'json' }, type: 'ajax', actionMethods: { read: 'POST' }, id: 'user_remote' }); User.localProxy = new Ext.data.LocalStorageProxy({ model: 'User', type: 'localstorage', id: 'user_local' });Last edited by mikermcneil; 13 Apr 2011 at 7:33 AM. Reason: added code example
Similar Threads
-
Local Storage
By tomalex0 in forum Sencha Touch 1.x: DiscussionReplies: 2Last Post: 20 Dec 2010, 6:24 AM -
Saving List data to local storage
By Akhenaten in forum Sencha Touch 1.x: DiscussionReplies: 6Last Post: 19 Dec 2010, 5:36 PM -
[FIXED] Invalid id for records loaded from local storage
By Mis63 in forum Sencha Touch 1.x: BugsReplies: 1Last Post: 13 Dec 2010, 10:45 AM -
Store.sync() only seems to work from site > local storage, not local storage > site
By rdougan in forum Sencha Touch 1.x: BugsReplies: 2Last Post: 3 Jun 2010, 10:53 AM -
idea: local storage using Flash Shared objects
By PromaneX in forum Community DiscussionReplies: 0Last Post: 2 Jun 2008, 4:53 AM


Reply With Quote