Hello,
i'm trying to learn sencha touch, i followed this tutorial http://lalexgraham.wordpress.com/201...p-proxy-store/ all is working but i have a problem with the pullrefresh plugin.
view:
Code:
....
plugins: [
{
xtype: 'component',
refreshFn: function(plugin) {
console.log('refresh pulled');
this.fireEvent('refreshlist',this);
},
type: 'pullrefresh'
}
]
...
controller:
Code:
....
onRefreshList: function(target) {
console.log('onrefreshlist angekommen');
var remotestore = Ext.getStore('MarketRemoteStore');
remotestore.on({load:'onMarketsStoreLoad', scope: this});
remotestore.load({addRecord:true});
},
onMarketsStoreLoad: function() {
console.log('onmarketsStoreLoad');
var marketLocalStore = Ext.getStore('MarketLocalStore');
var marketStore = Ext.getStore('MarketRemoteStore');
marketStore.each(function(item){marketLocalStore.add(item.copy()); });
marketLocalStore.sync();
console.log(marketLocalStore.getCount());
console.log(marketLocalStore);
}
model:
Code:
Ext.define('ss_test.model.market', {
extend: 'Ext.data.Model',
config: {
idProperty: 'ID',
identifier: 'uuid',
useCache: false,
fields: [
{
name: 'Name',
type: 'string'
},
{
name: 'logo',
type: 'string'
},
{
name: 'ID',
type: 'auto'
}
],
proxy: {
type: 'localstorage',
id: 'ProxyMarket'
}
}
});
remotestore:
Code:
Ext.define('ss_test.store.MarketRemoteStore', {
extend: 'Ext.data.Store',
requires: [
'Ext.data.proxy.JsonP',
'ss_test.model.market'
],
config: {
model: 'ss_test.model.market',
pageSize: 3,
storeId: 'MarketRemoteStore',
proxy: {
type: 'jsonp',
url: 'http://test.localdomain.com/api/market/.json',
reader: {
type: 'json',
rootProperty: 'items',
useSimpleAccessors: false
}
}
}
});
localstore:
Code:
Ext.define('ss_test.store.MarketLocalStore', {
extend: 'Ext.data.Store',
requires: [
'ss_test.model.market'
],
config: {
model: 'ss_test.model.market',
pageSize: 3,
storeId: 'MarketLocalStore'
}
});
always when i use the pullrefresh it adds the same data again to localstorage.
i read in the forum and tried setting idProperty but nothing help.
i also renamed the ID field in the model to MarketID and add a mapping:ID to it and tryed but the idProperty field is in localstorage always different.
can someone help me whats the problem here