javascript - Sencha touch2, data in localstore not getting into localstorage -


model:

ext.define('skse.model.placeslocal',{     extend:'ext.data.model',     config:{         fields:['id', 'name','icon','required_stamps', 'active_stamps','description', 'campaign_id', 'user_favorites' , 'live_action_number'],          proxy: {         type: 'localstorage',         id  : 'local-places-id'      }      }  }); 

store:

ext.define('skse.store.placeslocal', {     extend:'ext.data.store',     config: {         storeid: 'placeslocal',         model: "skse.model.placeslocal",          sorters: 'name',         grouper: {             groupfn: function (item) {                 return item.get('name')[0];             }         },          groupdir: 'desc'       } }); 

offline - online store sync:

ext.define('skse.store.places',{     extend:'ext.data.store',      config:{          autoload:true,         autosync:true,          model:'skse.model.places',         sorters: 'name',         grouper: {             groupfn: function (item) {                 return item.get('name')[0];             }         },          groupdir: 'desc',         proxy:{             type:'ajax',             url:'http://localhost/campaigns/',             reader:{                 type:'json',                 //name of array results stored                 rootproperty:'results'             }         },          listeners: {                 load: function() {                      var placeslocal = ext.data.storemanager.lookup('placeslocal');                     // clear proxy offline store                        if (navigator.online) {                    console.log("hm");                      // loop through records , fill offline store                     this.each(function(record) {                          placeslocal.add(record.data);                      });                      // sync offline store                     placeslocal.sync();                       }                 }      }     } }); 

apparently placeslocalstore data, reason doesn't stored in localstorage.

key local-places-id appears in localstorage without data.

i think problem when that:

placeslocal.add(record.data); 

there's id field value in record.data. hence, record won't considered new. won't considered modified either, because has not modified, , won't considered deleted either (the explaination left exercice reader).

in other words, store, there's nothing sync. mission complete.

here's code of getnewrecords, used in sync method:

function() {     return this.data.filterby(function(item) {         // want phantom records valid         return item.phantom === true && item.isvalid();     }).items; } 

i suppose you've guessed need now, let me voluble:

var recordsdata = store.getrange().map(function(record) { return record.data }),     newrecords = placeslocal.add(recordsdata);  ext.each(newrecords, function(record) {     record.phantom = true; });  // should have plenty of work! placeslocal.sync(); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -