-
28 Oct 2011 3:52 AM #1
Unanswered: use syncstorage with Sensha Touch 2.
Unanswered: use syncstorage with Sensha Touch 2.
Hello, i have Ext.list associated with models whitch have syncstorage proxy type.
When I add record to my store then record shows in browser localstorage and store total count increment, but store data items array is empty.Code:Ext.define('myApp.store.mystore', { extend : 'Ext.data.Store', model : 'myApp.model.mymodel', requires: ['myApp.model.mymodel'], storeId : 'storeid', sorters : 'somerecord', getGroupString: function(record) { return record.get('somerecord')[0]; }, autoLoad : true }); Ext.define("myApp.model.mymodel", { extend: "Ext.data.Model", fields: [ {name: "id", type: "string"}, {name: "firstfieald", type: "string"}, {name: "secondfieald", type: "string"} ], proxy: { id: 'proxyid', type: 'syncstorage', key: 'myproxykey' } });
Please give me small work syncstorages example or tell me what i'm doing wrong.
-
28 Oct 2011 4:59 AM #2
@maxLodoss - That code looks right. How are you calling add()? And when are you calling sync()?
John
-
28 Oct 2011 5:33 AM #3
I create instanse of my model
After this code I can see my new instance model in browser localstorage .Code:var myInstance = Ext.create('myApp.model.mymodel',{ ... }); myInstance.save();
Then I restart my application and store should load data from localstorage (becouse autoload : true) and it try do it, but store data items array is empty.
I tried find solution in src, and i think problen in
sencha-io-debug.js read: function(operation, callback, scope)
line 1986
becouse operation.id is undefined
-
28 Oct 2011 5:36 AM #4
Typically you call sync() after save or add to get the data actually written to disk.
John
-
28 Oct 2011 5:58 AM #5
st2 documentation http://docs.sencha.com/touch/2-0/#!/...y.LocalStorage
Show that we can use store.add() + store.sync() or modelinstance.save() , but first solution doesn't work for me.


Reply With Quote