Web Interface For Lite Argus Control modules
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.

105 lines
5.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.data.JsonWriter"></div>/**
  16. * @class Ext.data.JsonWriter
  17. * @extends Ext.data.DataWriter
  18. * DataWriter extension for writing an array or single {@link Ext.data.Record} object(s) in preparation for executing a remote CRUD action.
  19. */
  20. Ext.data.JsonWriter = Ext.extend(Ext.data.DataWriter, {
  21. <div id="cfg-Ext.data.JsonWriter-encode"></div>/**
  22. * @cfg {Boolean} encode <p><tt>true</tt> to {@link Ext.util.JSON#encode JSON encode} the
  23. * {@link Ext.data.DataWriter#toHash hashed data} into a standard HTTP parameter named after this
  24. * Reader's <code>meta.root</code> property which, by default is imported from the associated Reader. Defaults to <tt>true</tt>.</p>
  25. * <p>If set to <code>false</code>, the hashed data is {@link Ext.util.JSON#encode JSON encoded}, along with
  26. * the associated {@link Ext.data.Store}'s {@link Ext.data.Store#baseParams baseParams}, into the POST body.</p>
  27. * <p>When using {@link Ext.data.DirectProxy}, set this to <tt>false</tt> since Ext.Direct.JsonProvider will perform
  28. * its own json-encoding. In addition, if you're using {@link Ext.data.HttpProxy}, setting to <tt>false</tt>
  29. * will cause HttpProxy to transmit data using the <b>jsonData</b> configuration-params of {@link Ext.Ajax#request}
  30. * instead of <b>params</b>.</p>
  31. * <p>When using a {@link Ext.data.Store#restful} Store, some serverside frameworks are
  32. * tuned to expect data through the jsonData mechanism. In those cases, one will want to set <b>encode: <tt>false</tt></b>, as in
  33. * let the lower-level connection object (eg: Ext.Ajax) do the encoding.</p>
  34. */
  35. encode : true,
  36. <div id="cfg-Ext.data.JsonWriter-encodeDelete"></div>/**
  37. * @cfg {Boolean} encodeDelete False to send only the id to the server on delete, true to encode it in an object
  38. * literal, eg: <pre><code>
  39. {id: 1}
  40. * </code></pre> Defaults to <tt>false</tt>
  41. */
  42. encodeDelete: false,
  43. constructor : function(config){
  44. Ext.data.JsonWriter.superclass.constructor.call(this, config);
  45. },
  46. <div id="method-Ext.data.JsonWriter-render"></div>/**
  47. * <p>This method should not need to be called by application code, however it may be useful on occasion to
  48. * override it, or augment it with an {@link Function#createInterceptor interceptor} or {@link Function#createSequence sequence}.</p>
  49. * <p>The provided implementation encodes the serialized data representing the Store's modified Records into the Ajax request's
  50. * <code>params</code> according to the <code>{@link #encode}</code> setting.</p>
  51. * @param {Object} Ajax request params object to write into.
  52. * @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}.
  53. * @param {Object/Object[]} data Data object representing the serialized modified records from the Store. May be either a single object,
  54. * or an Array of objects - user implementations must handle both cases.
  55. */
  56. render : function(params, baseParams, data) {
  57. if (this.encode === true) {
  58. // Encode here now.
  59. Ext.apply(params, baseParams);
  60. params[this.meta.root] = Ext.encode(data);
  61. } else {
  62. // defer encoding for some other layer, probably in {@link Ext.Ajax#request}. Place everything into "jsonData" key.
  63. var jdata = Ext.apply({}, baseParams);
  64. jdata[this.meta.root] = data;
  65. params.jsonData = jdata;
  66. }
  67. },
  68. <div id="method-Ext.data.JsonWriter-createRecord"></div>/**
  69. * Implements abstract Ext.data.DataWriter#createRecord
  70. * @protected
  71. * @param {Ext.data.Record} rec
  72. * @return {Object}
  73. */
  74. createRecord : function(rec) {
  75. return this.toHash(rec);
  76. },
  77. <div id="method-Ext.data.JsonWriter-updateRecord"></div>/**
  78. * Implements abstract Ext.data.DataWriter#updateRecord
  79. * @protected
  80. * @param {Ext.data.Record} rec
  81. * @return {Object}
  82. */
  83. updateRecord : function(rec) {
  84. return this.toHash(rec);
  85. },
  86. <div id="method-Ext.data.JsonWriter-destroyRecord"></div>/**
  87. * Implements abstract Ext.data.DataWriter#destroyRecord
  88. * @protected
  89. * @param {Ext.data.Record} rec
  90. * @return {Object}
  91. */
  92. destroyRecord : function(rec){
  93. if(this.encodeDelete){
  94. var data = {};
  95. data[this.meta.idProperty] = rec.id;
  96. return data;
  97. }else{
  98. return rec.id;
  99. }
  100. }
  101. });</pre>
  102. </body>
  103. </html>