Properties Methods Events Config Options Direct Link

# Class Ext.data.DataWriter

Package: | Ext.data
Defined In: | DataWriter.js
Class: | DataWriter
Subclasses: | JsonWriter, XmlWriter
Extends: | Object

Ext.data.DataWriter facilitates create, update, and destroy actions between an Ext.data.Store and a server-side framework. A Writer enabled Store will automatically manage the Ajax requests to perform CRUD actions on a Store.

Ext.data.DataWriter is an abstract base class which is intended to be extended and should not be created directly. For existing implementations, see Ext.data.JsonWriter.

Creating a writer is simple:

    var writer = new Ext.data.JsonWriter();

The proxy for a writer enabled store can be configured with a simple `url`:

    // Create a standard HttpProxy instance.
    var proxy = new Ext.data.HttpProxy({
        url: 'app.php/users'
    });

For finer grained control, the proxy may also be configured with an `api`:

    // Use the api specification
    var proxy = new Ext.data.HttpProxy({
        api: {
            read    : 'app.php/users/read',
            create  : 'app.php/users/create',
            update  : 'app.php/users/update',
            destroy : 'app.php/users/destroy'
        }
    });

Creating a Writer enabled store:

    var store = new Ext.data.Store({
        proxy: proxy,
        reader: reader,
        writer: writer
    });

## 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
| 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
| saveRecord : Function Abstract method that should be implemented in all subclasses (e.g.: JsonWriter.saveRecord | 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

Property | Defined By
--- | ---
| meta : Mixed This DataWriter's configured metadata as passed to the constructor. | DataWriter

## Public Methods

Method | Defined By
--- | ---
| DataWriter( `Object meta`, `Object recordType` ) Create a new DataWriter Create a new DataWriter Parameters: `meta` : Object Metadata configuration options (implementation-specific) `recordType` : Object Either an Array of field definition objects as specified in Ext.data.Record.create, or an Ext.data.Record object created using Ext.data.Record.create. Returns: void | DataWriter
| render( `String action`, `Record[] rs`, `Object params`, `Object data` ) : void abstract method meant to be overridden by all DataWriter extensions. It's the extension's job to apply the "data" to... abstract method meant to be overridden by all DataWriter extensions. It's the extension's job to apply the "data" to the "params". The data-object provided to render is populated with data according to the meta-info defined in the user's DataReader config, Parameters: `action` : String [Ext.data.Api.actions.create|read|update|destroy] `rs` : Record[] Store recordset `params` : Object Http params to be sent to server. `data` : Object object populated according to DataReader meta-data. Returns: void | DataWriter
| write( `String action`, `Object params`, `Record/Record[] rs` ) : void Writes data in preparation for server-write action. Simply proxies to DataWriter#update, DataWriter#create DataWrite... Writes data in preparation for server-write action. Simply proxies to DataWriter#update, DataWriter#create DataWriter#destroy. Parameters: `action` : String [CREATE|UPDATE|DESTROY] `params` : Object The params-hash to write-to `rs` : Record/Record[] The recordset write. Returns: void | DataWriter

## Public Events

This class has no public events.