1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    66
    Vote Rating
    0
    Answers
    4
    Gaspard22 is on a distinguished road

      0  

    Default Unanswered: Store.removeAll() and localStorage

    Unanswered: Store.removeAll() and localStorage


    Hello, i need to understand how the clearing method works, because after using store.removeAll(), the instance of my proxy seems to disappear in the localStorage of Chrome.

    I load some patients associated with docs(which are a array of images), and a photo, i display these images in a list when i select a patient.

    then i remove all my records , to setData from the record of a new patient.

    This is working, but just once, after the removeAll(), the proxy used for my first patient is gone. so after switching again from my second to the first patient, my list is empty.

    Code:
     loadingPatient: function(list, record) {        
            
           this.getMain().push({
            xtype:'patientdetail',
            title: record.get('CON_LASTNAME') +' '+record.get('CON_FIRSTNAME'),
            data : record.data
            
           });
      
        var theStore=Ext.getStore('eventActe');
         theStore.filterBy(function(rec){
                 return rec && rec.get('CON_ID') == record.get('CON_ID')
            });
          theStore.load();
        
           var form = this.getFichePat();
           form.updateWithRecord(record);
     
           var imagStore=Ext.getStore('radios');
           imagStore.removeAll();
            imagStore.sync();
    
    
           imagStore.setData(record.get('docs'));
           imagStore.load();
           imagStore.sync();
           
           var imgs = this.getTest();
           imgs.refresh();
        },
    my Store

    Code:
    Ext.define('CWFSE.store.ImagerieStore', {
        extend: 'Ext.data.Store',
        requires: ['CWFSE.model.Document'],
     
        config: {
            model: 'CWFSE.model.Document',
            storeId: 'radios',
            autoLoad: true,
            autoSync: true,
                  proxy: {
                    id : 'imagesProxy',
                type: 'localstorage',             
                reader: {
                    type: 'json',
                   rootProperty:'files'               
                }
            }
        }
    
    
    });
    this is the record.get('docs');

    [Object, Object, Object, Object, Object, Object, Object, Object]
    • 0: Object
      • CON_ID: 1
      • UPL_FILENAME: "png18B.png"
      • UPL_ID: 3
      • UPL_IP: "192.168.0.254"
      • UPL_NAME: "radio1.png"
      • UPL_PATH: "http://192.168.0.34/thumb/4036c36a16ef221529f77f2989f4dc57d1287d91/125/125"
      • UPL_SIZE: "607000"
      • UPL_TOKEN: "4036c36a16ef221529f77f2989f4dc57d1287d91"
      • UPL_TYPE: "image/png"
      • id: "1f0901d6-881b-43e3-b89f-de6ef668599d"
      • patient_id: null
      • xindex: 1



  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    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 not quite sure what you are asking about. Is it that you can only use removeAll once?
    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 Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    66
    Vote Rating
    0
    Answers
    4
    Gaspard22 is on a distinguished road

      0  

    Default


    The pb is that once i use removeAll() or getProxy().clear() , i lost my proxy or a reference to the proxy in the ressources / local Storage.

    I use a navigation view to display a list of users, and a carousel for the multiple views needed for details. the Selection made in the list loads data in the localstorage but so when i select a new user i add some data to the localstorage.
    To avoid a memory pb i want to clear data from my proxy before adding the data from my new user, but using removeAll() destroy the ref or the object i'm using.

    thanks for help

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    66
    Vote Rating
    0
    Answers
    4
    Gaspard22 is on a distinguished road

      0  

    Default


    well i found a solution, but when i migrated to 2.1 the solution fail to work

    Code:
    showDetail: function(list, record) { 
    
    
           var imagStore=Ext.create('Ext.data.Store', {
                            model: 'CWFSE.model.Document',// use a model
                            data: record.get('docs'), // set the store data as the tasks array
                           });
           this.getTest().setStore(imagStore);
    }

Thread Participants: 1