Once we have added, modified, or even deleted our original data we should send our changes to our server. The Ext allows us to do that by using a writer to encode our data to the right format. We have two types of writers available, for JSON and XML format.
Let's modify our store
class and define a JSON writer to our proxy:
Ext.define('MyApp.store.Invoices',{ extend : 'Ext.data.Store', model : 'MyApp.model.Invoice', //Ajax proxy with JSON reader and writer proxy : { type : 'ajax', url : 'serverside/invoices.json', reader : { type : 'json', root : 'data' }, writer : { type : 'json', allowSingle : false } } });
By setting a writer
property we can define the type of format to encode our data. In this case we are setting json
in the type
property. Also we have defined the allowSingle
property to false
. This means that even if we modify only one model, it will be sent wrapped in an array. This way we will always receive...