PDA

View Full Version : Saving form updates in local JSON file



SYZ
2 Nov 2012, 1:28 AM
Hi All,

I'm following the sencha website example "account manager" and I'm trying to update the local JSON file after the form cell content is modified. However, I can only see the update results in chrome network POST request, the local json file remains unchanged. How can I update my local JSON file?

My store:


Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
storeId: 'myStore',
autoLoad: true,
autoSync: true,
proxy: {
type: 'ajax',
url: 'data/users.json',
api: {
read: 'data/users.json',
update: 'data/users.json'
},
reader: {
type: 'json',
root: 'users',
successProperty: 'success'
},
writer: {
type: 'json',
root: 'users',
encode: true,
writeAllFields: false
},
actionMethods: {
create: 'POST', read: 'POST', update: 'POST', destroy: 'POST'
}
}
});


My controller:


init: function() {
this.control({
'useredit button[action=save]': {
click: this.updateUser
}
});
},

updateUser: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
win.close();
if (record.dirty) {
record.commit();
}
this.getUsersStore().sync();
}


Thanks a lot for your help!

desp
2 Nov 2012, 2:45 AM
You simply can't do this cause of security :)