You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
22 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.data.JsonP.Ext_data_DataWriter({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":["Ext.data.JsonWriter","Ext.data.XmlWriter"],"extends":null,"uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Subclasses</h4><div class='dependency'><a href='#!/api/Ext.data.JsonWriter' rel='Ext.data.JsonWriter' class='docClass'>Ext.data.JsonWriter</a></div><div class='dependency'><a href='#!/api/Ext.data.XmlWriter' rel='Ext.data.XmlWriter' class='docClass'>Ext.data.XmlWriter</a></div><h4>Files</h4><div class='dependency'><a href='source/DataWriter.html#Ext-data-DataWriter' target='_blank'>DataWriter.js</a></div></pre><div class='doc-contents'><p><a href=\"#!/api/Ext.data.DataWriter\" rel=\"Ext.data.DataWriter\" class=\"docClass\">Ext.data.DataWriter</a> facilitates create, update, and destroy actions between\nan <a href=\"#!/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Ext.data.Store</a> and a server-side framework. A Writer enabled Store will\nautomatically manage the Ajax requests to perform CRUD actions on a Store.</p>\n\n\n<p><a href=\"#!/api/Ext.data.DataWriter\" rel=\"Ext.data.DataWriter\" class=\"docClass\">Ext.data.DataWriter</a> is an abstract base class which is intended to be extended\nand should not be created directly. For existing implementations, see\n<a href=\"#!/api/Ext.data.JsonWriter\" rel=\"Ext.data.JsonWriter\" class=\"docClass\">Ext.data.JsonWriter</a>.</p>\n\n\n<p>Creating a writer is simple:</p>\n\n\n<pre><code>var writer = new <a href=\"#!/api/Ext.data.JsonWriter\" rel=\"Ext.data.JsonWriter\" class=\"docClass\">Ext.data.JsonWriter</a>({\n encode: false // &lt;--- false causes data to be printed to jsonData config-property of Ext.Ajax#reqeust\n});\n</code></pre>\n\n\n<ul>\n<li><p>Same old JsonReader as Ext-2.x:</p></li>\n</ul>\n\n\n<pre><code>var reader = new <a href=\"#!/api/Ext.data.JsonReader\" rel=\"Ext.data.JsonReader\" class=\"docClass\">Ext.data.JsonReader</a>({idProperty: 'id'}, [{name: 'first'}, {name: 'last'}, {name: 'email'}]);\n</code></pre>\n\n\n\n\n<p>The proxy for a writer enabled store can be configured with a simple <code>url</code>:</p>\n\n\n<pre><code>// Create a standard HttpProxy instance.\nvar proxy = new <a href=\"#!/api/Ext.data.HttpProxy\" rel=\"Ext.data.HttpProxy\" class=\"docClass\">Ext.data.HttpProxy</a>({\n url: 'app.php/users' // &lt;--- Supports \"provides\"-type urls, such as '/users.json', '/products.xml' (Hello Rails/Merb)\n});\n</code></pre>\n\n\n<p>For finer grained control, the proxy may also be configured with an <code>API</code>:</p>\n\n\n<pre><code>// Maximum flexibility with the API-configuration\nvar proxy = new <a href=\"#!/api/Ext.data.HttpProxy\" rel=\"Ext.data.HttpProxy\" class=\"docClass\">Ext.data.HttpProxy</a>({\n api: {\n read : 'app.php/users/read',\n create : 'app.php/users/create',\n update : 'app.php/users/update',\n destroy : { // &lt;--- Supports object-syntax as well\n url: 'app.php/users/destroy',\n method: \"DELETE\"\n }\n }\n});\n</code></pre>\n\n\n<p>Pulling it all together into a Writer-enabled Store:</p>\n\n\n<pre><code>var store = new <a href=\"#!/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Ext.data.Store</a>({\n proxy: proxy,\n reader: reader,\n writer: writer,\n autoLoad: true,\n autoSave: true // -- Cell-level updates.\n});\n</code></pre>\n\n\n<p>Initiating write-actions <b>automatically</b>, using the existing Ext2.0 Store/Record API:</p>\n\n\n<pre><code>var rec = store.getAt(0);\nrec.set('email', 'foo@bar.com'); // &lt;--- Immediately initiates an UPDATE action through configured proxy.\n\nstore.remove(rec); // &lt;---- Immediately initiates a DESTROY action through configured proxy.\n</code></pre>\n\n\n<p>For <b>record/batch</b> updates, use the Store-configuration <a href=\"#!/api/Ext.data.Store-cfg-autoSave\" rel=\"Ext.data.Store-cfg-autoSave\" class=\"docClass\">autoSave:false</a></p>\n\n\n<pre><code>var store = new <a href=\"#!/api/Ext.data.Store\" rel=\"E