3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.data.JsonWriter"></div>/**
10 * @class Ext.data.JsonWriter
11 * @extends Ext.data.DataWriter
12 * DataWriter extension for writing an array or single {@link Ext.data.Record} object(s) in preparation for executing a remote CRUD action.
14 Ext.data.JsonWriter = function(config) {
15 Ext.data.JsonWriter.superclass.constructor.call(this, config);
17 // careful to respect "returnJson", renamed to "encode"
18 // TODO: remove after Ext-3.0.1 release
19 if (this.returnJson != undefined) {
20 this.encode = this.returnJson;
23 Ext.extend(Ext.data.JsonWriter, Ext.data.DataWriter, {
24 <div id="cfg-Ext.data.JsonWriter-returnJson"></div>/**
25 * @cfg {Boolean} returnJson <b>Deprecated, will be removed in Ext-3.0.1</b>. Use {@link Ext.data.JsonWriter#encode} instead.
27 returnJson : undefined,
28 <div id="cfg-Ext.data.JsonWriter-encode"></div>/**
29 * @cfg {Boolean} encode <tt>true</tt> to {@link Ext.util.JSON#encode encode} the
30 * {@link Ext.data.DataWriter#toHash hashed data}. Defaults to <tt>true</tt>. When using
31 * {@link Ext.data.DirectProxy}, set this to <tt>false</tt> since Ext.Direct.JsonProvider will perform
32 * its own json-encoding. In addition, if you're using {@link Ext.data.HttpProxy}, setting to <tt>false</tt>
33 * will cause HttpProxy to transmit data using the <b>jsonData</b> configuration-params of {@link Ext.Ajax#request}
34 * instead of <b>params</b>. When using a {@link Ext.data.Store#restful} Store, some serverside frameworks are
35 * tuned to expect data through the jsonData mechanism. In those cases, one will want to set <b>encode: <tt>false</tt></b>, as in
36 * let the lower-level connection object (eg: Ext.Ajax) do the encoding.
40 <div id="method-Ext.data.JsonWriter-render"></div>/**
41 * Final action of a write event. Apply the written data-object to params.
42 * @param {Object} http params-object to write-to.
43 * @param {Object} baseParams as defined by {@link Ext.data.Store#baseParams}. The baseParms must be encoded by the extending class, eg: {@link Ext.data.JsonWriter}, {@link Ext.data.XmlWriter}.
44 * @param {Object/Object[]} data Data-object representing compiled Store-recordset.
46 render : function(params, baseParams, data) {
47 if (this.encode === true) {
49 Ext.apply(params, baseParams);
50 params[this.meta.root] = Ext.encode(data);
52 // defer encoding for some other layer, probably in {@link Ext.Ajax#request}. Place everything into "jsonData" key.
53 var jdata = Ext.apply({}, baseParams);
54 jdata[this.meta.root] = data;
55 params.jsonData = jdata;
58 <div id="method-Ext.data.JsonWriter-createRecord"></div>/**
59 * Implements abstract Ext.data.DataWriter#createRecord
61 * @param {Ext.data.Record} rec
64 createRecord : function(rec) {
65 return this.toHash(rec);
67 <div id="method-Ext.data.JsonWriter-updateRecord"></div>/**
68 * Implements abstract Ext.data.DataWriter#updateRecord
70 * @param {Ext.data.Record} rec
73 updateRecord : function(rec) {
74 return this.toHash(rec);
77 <div id="method-Ext.data.JsonWriter-destroyRecord"></div>/**
78 * Implements abstract Ext.data.DataWriter#destroyRecord
80 * @param {Ext.data.Record} rec
83 destroyRecord : function(rec) {