X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..c8256059947f3aa8f5b0a9a2acf55e2142bb4742:/docs/output/Ext.data.DataWriter.html diff --git a/docs/output/Ext.data.DataWriter.html b/docs/output/Ext.data.DataWriter.html index b8166186..9d702c88 100644 --- a/docs/output/Ext.data.DataWriter.html +++ b/docs/output/Ext.data.DataWriter.html @@ -1,47 +1,91 @@ -
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 +

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();
+
var writer = new Ext.data.JsonWriter({
+    encode: false   // <--- false causes data to be printed to jsonData config-property of Ext.Ajax#reqeust
+});
+

Same old JsonReader as Ext-2.x:

+
var reader = new Ext.data.JsonReader({idProperty: 'id'}, [{name: 'first'}, {name: 'last'}, {name: 'email'}]);

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'
+    url: 'app.php/users'    // <--- Supports "provides"-type urls, such as '/users.json', '/products.xml' (Hello Rails/Merb)
 });
-

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

-
// Use the api specification
+

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

+
// Maximum flexibility with the API-configuration
 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'
+        destroy : {  // <--- Supports object-syntax as well
+            url: 'app.php/users/destroy',
+            method: "DELETE"
+        }
     }
 });
-

Creating a Writer enabled store:

+

Pulling it all together into a Writer-enabled Store:

+
var store = new Ext.data.Store({
+    proxy: proxy,
+    reader: reader,
+    writer: writer,
+    autoLoad: true,
+    autoSave: true  // -- Cell-level updates.
+});
+

Initiating write-actions automatically, using the existing Ext2.0 Store/Record API:

+
var rec = store.getAt(0);
+rec.set('email', 'foo@bar.com');  // <--- Immediately initiates an UPDATE action through configured proxy.
+
+store.remove(rec);  // <---- Immediately initiates a DESTROY action through configured proxy.
+

For record/batch updates, use the Store-configuration autoSave:false

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

Config Options

Config OptionsDefined By
 createRecord : Function
Abstract method that should be implemented in all subclasses + writer: writer, + autoLoad: true, + autoSave: false // -- disable cell-updates +}); + +var urec = store.getAt(0); +urec.set('email', 'foo@bar.com'); + +var drec = store.getAt(1); +store.remove(drec); + +// Push the button! +store.save();

Config Options

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

Public Properties

This class has no public properties.

Public Methods

MethodDefined By

Public Properties

This class has no public properties.

Public Methods

MethodDefined By

Public Events

This class has no public events.
\ No newline at end of file +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

Public Events

This class has no public events.
\ No newline at end of file