1. #1
    Touch Premium Member
    Join Date
    Apr 2007
    Posts
    24
    Vote Rating
    0
    cassebn is on a distinguished road

      0  

    Default 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'
            
    }
        },
        
    autoLoadtrue
    });
           
    // 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 
    favorites.findRecord('name',record.data.name);
            
    favorites.remove(r);
            
    favorites.sync();
        } 

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,672
    Vote Rating
    747
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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+remove
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    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
                }]
            });
        }
    });

  4. #4
    Sencha User
    Join Date
    Oct 2010
    Location
    San Diego
    Posts
    12
    Vote Rating
    0
    SpNg is on a distinguished road

      0  

    Default


    I am also having this problem. Adding works fine, but removing is not syncing...

  5. #5
    Sencha User
    Join Date
    Apr 2010
    Posts
    4
    Vote Rating
    0
    chummy is on a distinguished road

      0  

    Default


    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.

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,672
    Vote Rating
    747
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ok, we can close this thread as it's working in the last couple versions now.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User
    Join Date
    Oct 2010
    Location
    San Diego
    Posts
    12
    Vote Rating
    0
    SpNg is on a distinguished road

      0  

    Default


    Yep this works for me now. The id field was the key. Thanks for the response!

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

      0  

    Default


    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).

  9. #9
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,672
    Vote Rating
    747
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by mikermcneil View Post
    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).
    So the fix worked in 1.1.0?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

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

      0  

    Default


    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

  1. Local Storage
    By tomalex0 in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 20 Dec 2010, 6:24 AM
  2. Saving List data to local storage
    By Akhenaten in forum Sencha Touch 1.x: Discussion
    Replies: 6
    Last Post: 19 Dec 2010, 5:36 PM
  3. [FIXED] Invalid id for records loaded from local storage
    By Mis63 in forum Sencha Touch 1.x: Bugs
    Replies: 1
    Last Post: 13 Dec 2010, 10:45 AM
  4. Replies: 2
    Last Post: 3 Jun 2010, 10:53 AM
  5. idea: local storage using Flash Shared objects
    By PromaneX in forum Community Discussion
    Replies: 0
    Last Post: 2 Jun 2008, 4:53 AM

Thread Participants: 8

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar