    DataWriter
      JsonWriter

# Class Ext.data.JsonWriter

Package: | Ext.data
Defined In: | JsonWriter.js
Class: | JsonWriter
Extends: | DataWriter

DataWriter extension for writing an array or single Ext.data.Record object(s) in preparation for executing a remote CRUD action.

## Config Options

Config Options | Defined By
--- | ---
| createRecord : Function Abstract method that should be implemented in all subclasses (e.g.: JsonWriter.createRecord) | DataWriter
| destroyRecord : Function Abstract method that should be implemented in all subclasses (e.g.: JsonWriter.destroyRecord) | DataWriter
| encode : Boolean true to JSON encode the hashed data into a standard HTTP parameter named after this Reader's meta.root property which... `true` to JSON encode the hashed data into a standard HTTP parameter named after this Reader's `meta.root` property which, by default is imported from the associated Reader. Defaults to `true`. If set to `false`, the hashed data is JSON encoded, along with the associated Ext.data.Store's baseParams, into the POST body. When using Ext.data.DirectProxy, set this to `false` since Ext.Direct.JsonProvider will perform its own json-encoding. In addition, if you're using Ext.data.HttpProxy, setting to `false` will cause HttpProxy to transmit data using the jsonData configuration-params of Ext.Ajax.request instead of params. When using a Ext.data.Store.restful Store, some serverside frameworks are tuned to expect data through the jsonData mechanism. In those cases, one will want to set encode: `false`, as in let the lower-level connection object (eg: Ext.Ajax) do the encoding. | JsonWriter
| encodeDelete : Boolean False to send only the id to the server on delete, true to encode it in an object literal, eg: {id: 1} Defaults to fa... False to send only the id to the server on delete, true to encode it in an object literal, eg:
    {id: 1}
Defaults to `false` | JsonWriter
| listful : Boolean false by default. Set true to have the DataWriter always write HTTP params as a list, even when acting upon a single... `false` by default. Set `true` to have the DataWriter always write HTTP params as a list, even when acting upon a single record. | DataWriter
| updateRecord : Function Abstract method that should be implemented in all subclasses (e.g.: JsonWriter.updateRecord | DataWriter
| writeAllFields : Boolean false by default. Set true to have DataWriter return ALL fields of a modified record -- not just those that changed.... `false` by default. Set `true` to have DataWriter return ALL fields of a modified record -- not just those that changed. `false` to have DataWriter only request modified fields from a record. | DataWriter

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| apply( Object params, Object baseParams, String action, Record/Record[] rs ) : void Compiles a Store recordset into a data-format defined by an extension such as Ext.data.JsonWriter or Ext.data.XmlWrit... Compiles a Store recordset into a data-format defined by an extension such as Ext.data.JsonWriter or Ext.data.XmlWriter in preparation for a server-write action. The first two params are similar similar in nature to Ext.apply, Where the first parameter is the receiver of paramaters and the second, baseParams, the source. Parameters: `params` : Object The request-params receiver. `baseParams` : Object as defined by Ext.data.Store.baseParams. The baseParms must be encoded by the extending class, eg: Ext.data.JsonWriter, Ext.data.XmlWriter. `action` : String [create|update|destroy] `rs` : Record/Record[] The recordset to write, the subject(s) of the write action. Returns: void | DataWriter
| createRecord( Ext.data.Record rec ) : Object Implements abstract Ext.data.DataWriter#createRecord Implements abstract Ext.data.DataWriter#createRecord Parameters: `rec` : Ext.data.Record Returns: `Object` | JsonWriter
| destroyRecord( Ext.data.Record rec ) : Object Implements abstract Ext.data.DataWriter#destroyRecord Implements abstract Ext.data.DataWriter#destroyRecord Parameters: `rec` : Ext.data.Record Returns: `Object` | JsonWriter
| render( Object Ajax, Object baseParams, Object/Object[] data ) : void This method should not need to be called by application code, however it may be useful on occasion to override it, or... This method should not need to be called by application code, however it may be useful on occasion to override it, or augment it with an interceptor or sequence. The provided implementation encodes the serialized data representing the Store's modified Records into the Ajax request's `params` according to the `encode` setting. Parameters: `Ajax` : Object request params object to write into. `baseParams` : Object as defined by Ext.data.Store.baseParams. The baseParms must be encoded by the extending class, eg: Ext.data.JsonWriter, Ext.data.XmlWriter. `data` : Object/Object[] Data object representing the serialized modified records from the Store. May be either a single object, or an Array of objects - user implementations must handle both cases. Returns: void | JsonWriter
| toArray( Hash data ) : [Object] Converts a Hashed Ext.data.Record to fields-array array suitable for encoding to xml via XTemplate, eg: &lt;tpl for="... Converts a Hashed Ext.data.Record to fields-array array suitable for encoding to xml via XTemplate, eg: `
    <tpl for="."><{name}>{value}</{name}</tpl>
` eg, non-phantom: `
    {id: 1, first: 'foo', last: 'bar'} --> [{name: 'id', value: 1}, {name: 'first', value: 'foo'}, {name: 'last', value: 'bar'}]
` Phantom records will have had their idProperty omitted in toHash if determined to be auto-generated. Non AUTOINCREMENT pks should have been protected. Parameters: `data` : Hash Hashed by Ext.data.DataWriter#toHash Returns: `[Object]` Array of attribute-objects. | DataWriter
| toHash( Ext.data.Record rec, Object config ) : Object Converts a Record to a hash, taking into account the state of the Ext.data.Record along with configuration properties... Converts a Record to a hash, taking into account the state of the Ext.data.Record along with configuration properties related to its rendering, such as writeAllFields, phantom, getChanges and idProperty Parameters: `rec` : Ext.data.Record The Record from which to create a hash. `config` : Object NOT YET IMPLEMENTED. Will implement an exlude/only configuration for fine-control over which fields do/don't get rendered. Returns: `Object` | DataWriter
| updateRecord( Ext.data.Record rec ) : Object Implements abstract Ext.data.DataWriter#updateRecord Implements abstract Ext.data.DataWriter#updateRecord Parameters: `rec` : Ext.data.Record Returns: `Object` | JsonWriter

## Public Events

This class has no public events.