1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    23
    Vote Rating
    0
    francescosyd is on a distinguished road

      0  

    Default Data Store Delete All/ Remove All Items

    Data Store Delete All/ Remove All Items


    Hi all,

    I have set up a data store with a data model set to localStoreage and I would like to delete all items/records. My application is running locally under file://

    Here is my code:

    Ext.regModel("Message", {
    fields: [
    { name: "MessageId", type: "int" },
    { name: "Msg", type: "string" }
    ],
    proxy: {
    type: 'localstorage',
    id: 'stored-inbox'
    }
    });

    Ext.regStore('Messages', {
    model: 'Message',
    storeId: 'messagesStore',
    autoLoad: true
    });

    //delete methods tried
    Ext.StoreMgr.clear('Messages');

    Ext.StoreMgr.clear('messagesStore');

    store.destroy();

    store.removeAll();

    store.sync(); //called after destroy/removeAll methods

    The only way of deleting the localStorage items I can find that works is by calling localStorage.clear();

    Has anyone got any ideas? Is it perhaps not working because I'm working from a local file:// and not a domain?

    thanks

    Francesco

  2. #2
    Ext User
    Join Date
    Mar 2007
    Posts
    4
    Vote Rating
    1
    chwagssd is on a distinguished road

      1  

    Default Same here

    Same here


    For me this worked:

    deviceStore.getProxy().clear();

    Where deviceStore was a
    Code:
    deviceStore = new Ext.data.Store({
    	        model: 'Device',
    	        
    	        //autoLoad : true,
    	    });
    And the device model was connected to a localstorageproxy

    Code:
    var Device = Ext.regModel('Device', {
                fields: [
                    {name: 'pairing_key', type: 'string'},
                    {name: 'pairing_token', type: 'string'},
                    {name: 'pairing_name', type: 'string'},
                    {name: 'pairing_date',    type: 'string'},
                    {name: 'device_name',	type:'device_name'}
                ],
                validations: [
                    {type: 'presence',  field: 'pairing_key', message : 'A pairing key is required.'},
                    {type: 'presence',  field: 'pairing_name'},
                    {type: 'presence',  field: 'device_name', message : 'A name is required, such as "Family Room"'},
                ],
                proxy: {
    	        	  type: 'localstorage',
    	        	  id  : 'avtouch-devices',
    	        	  proxy: {
    	                  idProperty: 'devices_store'
    	              }
    	        },
            });

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    23
    Vote Rating
    0
    francescosyd is on a distinguished road

      0  

    Default


    Hi chwagssd,

    thanks for the tip. That worked for me too!

    cheers

    Francesco

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    4
    Vote Rating
    1
    chwagssd is on a distinguished road

      0  

    Default


    Cool It took me like 4 hours to get to this working point. It's perfect for wipe-all-data needs, but I find it implies a larger problem with the localstorage proxy, since model.save() and store.sync() are not permanently updating the browser's window.localStorage.

    Interestingly, if I add, then sync, then update a record, then sync it sticks... but throw a refresh of the browser in there after add and then the update never sticks.

    At least this serves as a workaround for the case at hand

  5. #5
    Ext User
    Join Date
    Jan 2011
    Posts
    2
    Vote Rating
    -1
    youngilaboungi is an unknown quantity at this point

      0  

    Default


    Hello,

    I cannot get this figured out.
    here is my code
    Code:
    touchadmin.processOrdersAjax = {
            getRecentOrders : function()
            {
                var myMask = new Ext.LoadMask(Ext.getBody());
                myMask.show();
                
                Ext.Ajax.request({
                        url: 'http://10.1.1.19/index.php/touchadmin/index/json/',
                        method: 'post',
                        params: {'met':'orders'},
                        success: function(response, opts)
                        {
                            myMask.hide();
                            
                            var result = Ext.util.JSON.decode(response.responseText);
                            //console.log(response.responseText);
                            if (!result['error'])
                            {
                                touchadmin.processOrdersAjax.ordersData = result['content'];//Ext.Msg.alert('Success', result['content'], true);
                                touchadmin.processOrdersAjax.insertRecords();
                            }
                            else
                            {
                                Ext.Msg.alert('Error', result['content'], true);
                                //return false;
                            }
                        },
                        failure: function(response, opts) {
                            myMask.hide();
                            console.log(response);
                            //return false;
                        }                
                });
            },
            insertRecords : function()
            {
                var ordersData = touchadmin.processOrdersAjax.ordersData;
                var totalCount = ordersData['count'];
                var full = ordersData['full'];
                var fullCount = full.length;
                var order;
                for (i=0; i<fullCount; i++)
                {
                    order = full[i];
                    touchadmin.processOrderStore.add({'firstname': order['address']['billing']['firstname'], 'lastname': order['address']['billing']['lastname']});
                }
             
    //            touchadmin.orderStore.add({'firstName': firstname, 'lastName': lastname});            
            }
        };
    
    var processOrderModel = Ext.regModel('ProcessOrder', {
            fields: [{name: 'id', type: 'int'},{name: 'firstname', type:'string'},{name:'lastname', type:'string'}]
        });
        
        touchadmin.processOrderStoreConfig = {
            model: 'ProcessOrder',
            sorters: 'firstname',
            getGroupString : function(record) {
                return record.get('firstname')[0];
            },
            proxy: {
                type: 'localstorage',
                id  : 'processOrder'
            },
            fields: [{name: 'id', type: 'int'},{name: 'firstname', type:'string'},{name:'lastname', type:'string'}]
    
        };
    
    var refreshBtn = new Ext.Button({
            disabled: false,
            ui: 'plain',
            iconCls: 'refresh',
            iconMask:true,
            handler: function() {
            touchadmin.ProcessOrder.update('');
                touchadmin.processOrderStore.getProxy().clear();
                touchadmin.processOrderStore.sync();
                //touchadmin.ProcessOrder.doLayout();
                console.log(touchadmin.processOrderStore);
                touchadmin.processOrdersAjax.getRecentOrders();
            }
        });
    
    touchadmin.processOrderStore = new Ext.data.Store(touchadmin.processOrderStoreConfig);
            
        touchadmin.ProcessOrder = new Ext.Panel({
                scroll: 'vertical',
                layout: Ext.is.Phone ? 'fit' : {
                    type: 'vbox',
                    align: 'center',
                    pack: 'center',
                },
                cls: 'demo-list',
                items: 
                [{
                    width: Ext.is.Phone ? undefined : 700,
                    height: Ext.is.Phone ? undefined : 500,
                    xtype: 'list',
                    onItemDisclosure: function(record, btn, index) {
                        //Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName'), Ext.emptyFn);
                    },
                    store: touchadmin.processOrderStore, //getRange(0, 9),
                    itemTpl: '<div class="contact"><strong>{firstname}</strong> {lastname}</div>'
                }],
                dockedItems: [{
                    dock: 'bottom',
                    xtype: 'toolbar',
                    items: [refreshBtn, {xtype: 'spacer'}, editBtn]
                }],
                listeners: {
                    beforerender: function() {
                        //touchadmin.orderStore.load();
                        touchadmin.processOrdersAjax.getRecentOrders();
                        //touchadmin.OrdersAjax.insertRecord();
                        //Ext.Msg.alert('before render process order');
                    }
                }    
            });
    I need to clear the list before fetching for more data or else the same data can be duplicated in the list

  6. #6
    Ext User
    Join Date
    Jan 2011
    Posts
    2
    Vote Rating
    -1
    youngilaboungi is an unknown quantity at this point

      -1  

    Default


    Hello,

    I cannot get this figured out.
    here is my code
    Code:
    touchadmin.processOrdersAjax = {
            getRecentOrders : function()
            {
                var myMask = new Ext.LoadMask(Ext.getBody());
                myMask.show();
                
                Ext.Ajax.request({
                        url: 'http://10.1.1.19/index.php/touchadmin/index/json/',
                        method: 'post',
                        params: {'met':'orders'},
                        success: function(response, opts)
                        {
                            myMask.hide();
                            
                            var result = Ext.util.JSON.decode(response.responseText);
                            //console.log(response.responseText);
                            if (!result['error'])
                            {
                                 touchadmin.processOrdersAjax.ordersData =  result['content'];//Ext.Msg.alert('Success', result['content'], true);
                                touchadmin.processOrdersAjax.insertRecords();
                            }
                            else
                            {
                                Ext.Msg.alert('Error', result['content'], true);
                                //return false;
                            }
                        },
                        failure: function(response, opts) {
                            myMask.hide();
                            console.log(response);
                            //return false;
                        }                
                });
            },
            insertRecords : function()
            {
                var ordersData = touchadmin.processOrdersAjax.ordersData;
                var totalCount = ordersData['count'];
                var full = ordersData['full'];
                var fullCount = full.length;
                var order;
                for (i=0; i<fullCount; i++)
                {
                    order = full[i];
                     touchadmin.processOrderStore.add({'firstname':  order['address']['billing']['firstname'], 'lastname':  order['address']['billing']['lastname']});
                }
             
    //            touchadmin.orderStore.add({'firstName': firstname, 'lastName': lastname});            
            }
        };
    
    var processOrderModel = Ext.regModel('ProcessOrder', {
            fields: [{name: 'id', type: 'int'},{name: 'firstname', type:'string'},{name:'lastname', type:'string'}]
        });
        
        touchadmin.processOrderStoreConfig = {
            model: 'ProcessOrder',
            sorters: 'firstname',
            getGroupString : function(record) {
                return record.get('firstname')[0];
            },
            proxy: {
                type: 'localstorage',
                id  : 'processOrder'
            },
            fields: [{name: 'id', type: 'int'},{name: 'firstname', type:'string'},{name:'lastname', type:'string'}]
    
        };
    
    var refreshBtn = new Ext.Button({
            disabled: false,
            ui: 'plain',
            iconCls: 'refresh',
            iconMask:true,
            handler: function() {
            touchadmin.ProcessOrder.update('');
                touchadmin.processOrderStore.getProxy().clear();
                touchadmin.processOrderStore.sync();
                //touchadmin.ProcessOrder.doLayout();
                console.log(touchadmin.processOrderStore);
                touchadmin.processOrdersAjax.getRecentOrders();
            }
        });
    
    touchadmin.processOrderStore = new Ext.data.Store(touchadmin.processOrderStoreConfig);
            
        touchadmin.ProcessOrder = new Ext.Panel({
                scroll: 'vertical',
                layout: Ext.is.Phone ? 'fit' : {
                    type: 'vbox',
                    align: 'center',
                    pack: 'center',
                },
                cls: 'demo-list',
                items: 
                [{
                    width: Ext.is.Phone ? undefined : 700,
                    height: Ext.is.Phone ? undefined : 500,
                    xtype: 'list',
                    onItemDisclosure: function(record, btn, index) {
                        //Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName'), Ext.emptyFn);
                    },
                    store: touchadmin.processOrderStore, //getRange(0, 9),
                    itemTpl: '<div class="contact"><strong>{firstname}</strong> {lastname}</div>'
                }],
                dockedItems: [{
                    dock: 'bottom',
                    xtype: 'toolbar',
                    items: [refreshBtn, {xtype: 'spacer'}, editBtn]
                }],
                listeners: {
                    beforerender: function() {
                        //touchadmin.orderStore.load();
                        touchadmin.processOrdersAjax.getRecentOrders();
                        //touchadmin.OrdersAjax.insertRecord();
                        //Ext.Msg.alert('before render process order');
                    }
                }    
            });
    I need to clear the list before fetching for more data or else the same data can be duplicated in the list

  7. #7
    Sencha User
    Join Date
    Sep 2011
    Location
    Vicenza, Veneto, Italy
    Posts
    18
    Vote Rating
    0
    MPeg is on a distinguished road

      0  

    Default


    try read this tutorial:
    http://goo.gl/ybwka
    Follow my blog at: MovableApp.com!
    http://twitter.com/#!/movableapp - My Sencha Touch Learning Experience

  8. #8
    Sencha User
    Join Date
    Jul 2011
    Posts
    3
    Vote Rating
    0
    StephenTS is on a distinguished road

      0  

    Default Still Not Working

    Still Not Working


    I tried the above tutorial, and this still does not work. Any more progress on this issue?

  9. #9
    Sencha User
    Join Date
    Aug 2011
    Location
    Mumbai, India
    Posts
    119
    Vote Rating
    4
    Sasha172 is on a distinguished road

      2  

    Default


    try

    Code:
    App.stores.MyStore.data.clear();

  10. #10
    Sencha User
    Join Date
    Dec 2012
    Posts
    30
    Vote Rating
    2
    gendaful is on a distinguished road

      0  

    Default Data Store Delete All/ Remove All Items

    Data Store Delete All/ Remove All Items


    If you are using proxy then use,

    var store = Ext.getStore('DataStoreName');
    store.getProxy().clear();
    store.data.clear();
    store.sync();

    If you are not using proxy then,

    var store = Ext.getStore('DataStoreName');
    store.removeAll();
    store.sync()

Similar Threads

  1. Replies: 3
    Last Post: 8 Jun 2010, 4:19 PM
  2. [MOVED] Please Implement Delete Key to delete items in addition to Delete Menu Item
    By markjlyon in forum Ext Designer: Help & Discussion
    Replies: 1
    Last Post: 11 May 2010, 7:48 AM
  3. Replies: 2
    Last Post: 15 May 2009, 2:19 AM
  4. Remove single Items from store (plzzzzzzz)
    By pomata in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 1 Feb 2008, 11:17 PM
  5. Replies: 1
    Last Post: 29 Jun 2007, 12:40 AM

Thread Participants: 6

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi