1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    45
    Vote Rating
    0
    peterkuli is on a distinguished road

      0  

    Default Objects not removed from localStore (0.97)

    Objects not removed from localStore (0.97)


    Hi everyone!

    First of all; I'm new to Sencha Touch so I might not know everything yet.

    I'm experimenting with localStore and am already able to store something in it. I use the developer tools of Chrome for debugging and if I look into Storage/Local Files I see the objects are stored as it should.

    Code:
    Ext.regModel('Assignment', {
    			fields: [				
    				{name:'name',	type:'string'}
    			]
    		});
    		
    var store = new Ext.data.Store({
    			proxy: new Ext.data.LocalStorageProxy({
    				id: 'test-assignment'
    				}),
    			model: 'Assignment'
    		});
    
    Ext.setup({
        onReady: function() {		
    		store.add({name: 'test1' });
    		store.add({name: 'test2' });
    		store.sync();
                    //some more code
    But now I'm trying to remove something from it:

    Code:
    store.remove(store.getAt(1));
    store.sync();
    When I look again at Storage/Local Files, I see that nothing's changed.

    I don't think this issue applies to me nor does this one.

  2. #2
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    31
    Vote Rating
    0
    herkulano is on a distinguished road

      0  

    Default


    i'm having the same problem in 0.98.

    after remove() the data is really removed from the store.data, but after sync() nothing happens to the localstorage data!

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Austin, TX
    Posts
    7
    Vote Rating
    0
    mikermcneil is on a distinguished road

      0  

    Default


    Hey guys,

    See chummy's post here:
    http://www.sencha.com/forum/showthre...nc-Local-Store

    The trick is to add an id field to your regModel:

    Code:
    	// Set up local user state model template
    	User.template = Ext.regModel('User', {
    		fields: [
    			'id', // PROTECTED DONT TOUCH (stupid problem w/ sencha's LocalStore model)
    
    			// 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'
    	});

Similar Threads

  1. [FIXED-339] LocalStore Proxy Record Remove Issue
    By aleg in forum Sencha Touch 1.x: Bugs
    Replies: 14
    Last Post: 16 Mar 2011, 10:02 AM
  2. Load object from localStore
    By Zielke in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 21 Sep 2010, 12:06 AM
  3. Thread Removed
    By vivitron in forum Community Discussion
    Replies: 10
    Last Post: 10 Jun 2009, 8:55 AM
  4. RowExpander removed from 2.1?
    By domainlabs in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 27 Jun 2008, 11:34 AM
  5. extjs throws string objects instead of error objects
    By bmf1972 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 22 Apr 2008, 3:14 AM

Thread Participants: 2

Tags for this Thread