As you can see. If I were to update a FIELD, i would receive an ALERT which would display me the TESTVALUEform my model. The first time it would be empty has my Store would be empty. But the 2nd time it should display me ROGER. but it does not. It is has my store was never synced.
Can somone help me ?
Here is my code :
Controller which receive the updated data (checked, it does receive the event)
Ext.define('Prototype.controller.MyController', {
extend: 'Ext.app.Controller',
config: {
control: {
"textfield": {
change: 'onTextfieldChange'
}
}
},
onTextfieldChange: function(textfield, newValue, oldValue, eOpts) {
Ext.getStore('localdb').load();
var test = Ext.getStore('localdb').last().get('testValue');
console.log(test);
Ext.getStore('localdb').add({testvalue: 'ROGER'});
Ext.getStore('localdb').sync();
}
});
Model :
Ext.define('Prototype.model.LocalData', {
extend: 'Ext.data.Model',
config: {
identifier: {
type: 'uuid'
},
proxy: {
type: 'localstorage',
id: 'test1'
},
fields: [
{
name: 'testValue'
}
]
}
});
Store :
Ext.define('Prototype.store.LocalStore', {
extend: 'Ext.data.Store',
requires: [
'Prototype.model.LocalData'
],
config: {
model: 'Prototype.model.LocalData',
storeId: 'localdb',
syncRemovedRecords: false,
proxy: {
type: 'localstorage',
id: 'test1'
}
}
});
Controller should be like this
Ext.getStore('localdb').load();
var test = Ext.getStore('localdb').last().get('testValue');
console.log(test);
var tested = Ext.create('Prototype.model.LocalData');
tested.set('testValue','roger');
Ext.getStore('localdb').add(tested);
Ext.getStore('localdb').sync();
I was not writing the data correctly -_-'