Results 1 to 4 of 4

Thread: Store.removeAll() and localStorage

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    93
    Answers
    7
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    I'm not quite sure what you are asking about. Is it that you can only use removeAll once?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    93
    Answers
    7
    Vote Rating
    0
      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
    93
    Answers
    7
    Vote Rating
    0
      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);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •