Ok, could you elaborate on "doesn't work" and perhaps post some code?
I know that code works in one of my apps so there must be a difference in how it's being used.
Note it's not removed from the database instantly. The db transaction happens in another thread.
If you want to execute code as soon as it is finished, add a write listener to the store before you sync.
Just figured out that the store needs to be loaded first to get removeAll() working. Is that the expected behavior?
Yes that would be consistent with how the localstorage proxy works.
When you do removeAll(), ST2 will get all the records in the store and remove them, and make a record of what was removed so it can be fetched with http://docs.sencha.com/touch/2-0/#!/...RemovedRecords .
Of course its there's nothing in the store to remove because it hasn't been loaded yet, it won't delete anything!
Then on a sync call, ST2 sends to the proxy the records to delete which the proxy will then do.
Thanks, it makes sense now.
Unfortunately I'm hitting another issue now. Probably I'm doing something dumb but multiple records are appearing in the DB now. I'm loading data from an online store to an sqlite store by the code below.
The console log shows the correct number of records. However if I browse the DB 2-3 copies of each record appearing. Is there any clue what could be the reason for that?Code:storeOnlineCustomer.load(function(){ storeOnlineCustomer.each(function (record) { storeOfflineCustomer.add(record); console.log('Customer: ', record.data); }); storeOfflineCustomer.sync(); me.redirectTo('home/'); });
Can you post the model definition?
Code:Ext.define('FieldServices.model.Customer', { extend: 'Ext.data.Model', alias: 'model.Customer', uses: [ 'FieldServices.model.Contact', 'FieldServices.model.Address' ], config: { fields: [ { name: 'id', type: 'int' }, { name: 'company', type: 'string' }, { name: 'created', type: 'int' }, { name: 'company_id', type: 'int' } ], hasMany: [ { model: 'FieldServices.model.Contact', autoLoad: true, foreignKey: 'customer_id', name: 'contacts' }, { model: 'FieldServices.model.Address', autoLoad: true, foreignKey: 'customer_id', name: 'address' } ] } });
Ok, I don't think it's going to work with the hasMany config for starters, but then neither does the localstorage proxy yet!
My solution for that is just to load stores in for the submodels with remoteFilter: true and then filter by their customer_id field.
But I can't see from that why multiple records are going into the database. Have you tried dropping the db table and starting again? Maybe it's a bug you've already fixed, but the proxy's not clever enough to try to fix the database on each load.
I have attached a list to SQLite store. The list contionusly shows loading sign. using Java Console I could see that store is loaded but only to 25 elements when actually in DB i have 155.
Is there some trick I am missing.
Store Code is as follows
added pagesize = 1000;Code:Ext.define('NDP.store.menuList', { extend: 'Ext.data.Store', requires: 'NDP.model.menuList', config : { model: 'NDP.model.menuList', autoLoad: true, root:'root' } });
Now it loads all the 154 records. But issue is it is not finishing meaning it is just showing "Loading"
If it's loading the records into the store, but they're not showing in the list, that sounds like an issue with the list, not with the proxy. The proxy's job is to get the records into the store - from there touch should take over.
I'm happy to have a look at the list if you don't mind posting the code for it.