Skip to content

Instantly share code, notes, and snippets.

@pphetra
Last active December 18, 2015 17:39
Show Gist options
  • Select an option

  • Save pphetra/5820137 to your computer and use it in GitHub Desktop.

Select an option

Save pphetra/5820137 to your computer and use it in GitHub Desktop.
store = Ext.create('Ext.data.Store', {
fields: [
'id',
'model',
'brand'
],
proxy: {
type: 'ajax',
url: '/sagi/service/car',
batchActions: false,
api: {
create: '/sagi/service/car/create',
read: '/sagi/service/car',
update: '/sagi/service/car/update',
destroy: '/sagi/service/car/destroy',
},
reader: {
type: 'json',
root: 'data',
idProperty: 'id'
},
writer: {
type: 'json',
encode: true,
allowSingle: true,
writeAllFields: true,
root: 'data'
}
}
});
store.load({
callback: function(records, operation, success) {
if (success) {
console.log(records)
} else {
console.log('server reported an error')
}
}
});
store.add({model: 'Hilux Vego', brand: 'Toyota'});
console.log(store.last().data);
store.getModifiedRecords()
store.sync()
store.getAt(2).set('model', 'Accord')
store.getModifiedRecords()
store.sync()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment