Results 1 to 2 of 2

Thread: How to save ajax proxy store data in localproxy

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default Unanswered: How to save ajax proxy store data in localproxy

    Need some help to save Ext.Store data in localstorage which connects to extrenal system (using rest webservice api).

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Posts
    2
    Vote Rating
    0
      0  

    Default

    you will need to download the data into the ajax store and then move the same into the offline store once the the online store is loaded

    In the example below the inv.models.NewsData is my model and should me a model for both online and offline store.

    Also your component should point to the the offlineStore.

    Code:
    inv.stores.NewsData = new Ext.data.Store({
        model: 'inv.models.NewsData',
        proxy: {
            type: 'scripttag',
            url: 'http://query.yahooapis.com/v1/public/yql',
            extraParams: {            format: 'json'        },
              reader: {
                  root: 'query.results.Results.RNSSummaries.RNSSummary'
              }
          }});
    
    this.offlineStore= new Ext.data.Store({
                  model: 'inv.models.NewsData',
                  proxy: new Ext.data.LocalStorageProxy({
                      id:'data', 
                     proxy:{idProperty:'RNSId'}
                  }), 
                 autoLoad: true,
                  autoSave: true 
             });
    
    this.inv.stores.NewsData.on('load',function(store,records,opts){
                      console.log("load from online"); 
                     this.offlineStore.proxy.clear(); 
                     this.inv.stores.NewsData.each(function (record){
                          var iconEach = this.offlineStore.add(record.data)[0];
                      },this);
                      this.offlineStore.sync();
                      console.log("loaded from online");
                 },this);

Tags for this Thread

Posting Permissions

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