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
37 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_JsonReader({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":["Ext.data.ArrayReader"],"extends":"Ext.data.DataReader","uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Hierarchy</h4><div class='subclass first-child'><a href='#!/api/Ext.data.DataReader' rel='Ext.data.DataReader' class='docClass'>Ext.data.DataReader</a><div class='subclass '><strong>Ext.data.JsonReader</strong></div></div><h4>Subclasses</h4><div class='dependency'><a href='#!/api/Ext.data.ArrayReader' rel='Ext.data.ArrayReader' class='docClass'>Ext.data.ArrayReader</a></div><h4>Files</h4><div class='dependency'><a href='source/JsonReader.html#Ext-data-JsonReader' target='_blank'>JsonReader.js</a></div></pre><div class='doc-contents'><p>Data reader class to create an Array of <a href=\"#!/api/Ext.data.Record\" rel=\"Ext.data.Record\" class=\"docClass\">Ext.data.Record</a> objects\nfrom a JSON packet based on mappings in a provided <a href=\"#!/api/Ext.data.Record\" rel=\"Ext.data.Record\" class=\"docClass\">Ext.data.Record</a>\nconstructor.</p>\n\n\n<p>Example code:</p>\n\n\n<pre><code>var myReader = new <a href=\"#!/api/Ext.data.JsonReader\" rel=\"Ext.data.JsonReader\" class=\"docClass\">Ext.data.JsonReader</a>({\n // metadata configuration options:\n <a href=\"#!/api/Ext.data.JsonReader-cfg-idProperty\" rel=\"Ext.data.JsonReader-cfg-idProperty\" class=\"docClass\">idProperty</a>: 'id'\n <a href=\"#!/api/Ext.data.JsonReader-cfg-root\" rel=\"Ext.data.JsonReader-cfg-root\" class=\"docClass\">root</a>: 'rows',\n <a href=\"#!/api/Ext.data.JsonReader-cfg-totalProperty\" rel=\"Ext.data.JsonReader-cfg-totalProperty\" class=\"docClass\">totalProperty</a>: 'results',\n <a href=\"#!/api/Ext.data.DataReader-cfg-messageProperty\" rel=\"Ext.data.DataReader-cfg-messageProperty\" class=\"docClass\">Ext.data.DataReader.messageProperty</a>: \"msg\" // The element within the response that provides a user-feedback message (optional)\n\n // the fields config option will internally create an <a href=\"#!/api/Ext.data.Record\" rel=\"Ext.data.Record\" class=\"docClass\">Ext.data.Record</a>\n // constructor that provides mapping for reading the record data objects\n <a href=\"#!/api/Ext.data.DataReader-cfg-fields\" rel=\"Ext.data.DataReader-cfg-fields\" class=\"docClass\">fields</a>: [\n // map Record&#39;s 'firstname' field to data object&#39;s key of same name\n {name: 'name', mapping: 'firstname'},\n // map Record&#39;s 'job' field to data object&#39;s 'occupation' key\n {name: 'job', mapping: 'occupation'}\n ]\n});\n</code></pre>\n\n\n<p>This would consume a JSON data object of the form:</p>\n\n\n<pre><code>{\n results: 2000, // Reader&#39;s configured <a href=\"#!/api/Ext.data.JsonReader-cfg-totalProperty\" rel=\"Ext.data.JsonReader-cfg-totalProperty\" class=\"docClass\">totalProperty</a>\n rows: [ // Reader&#39;s configured <a href=\"#!/api/Ext.data.JsonReader-cfg-root\" rel=\"Ext.data.JsonReader-cfg-root\" class=\"docClass\">root</a>\n // record data objects:\n { <a href=\"#!/api/Ext.data.JsonReader-cfg-idProperty\" rel=\"Ext.data.JsonReader-cfg-idProperty\" class=\"docClass\">id</a>: 1, firstname: 'Bill', occupation: 'Gardener' },\n { <a href=\"#!/api/Ext.data.JsonReader-cfg-idProperty\" rel=\"Ext.data.JsonReader-cfg-idProperty\" class=\"docClass\">id</a>: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },\n ...\n ]\n}\n</code></pre>\n\n\n<p><b><u>Automatic configuration using metaData</u></b></p>\n\n\n<p>It is possible to change a JsonReader's metadata at any time by including\na <b><tt>metaData</tt></b> property in the JSON data object. If the JSON data\nobject has a <b><tt>metaData</tt></b> property, a <a href=\"#!/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a>\nobject using this Reader will reconfigure itself to use the newly provided\nfield definition and fire its <a href=\"#!/api/Ext.data.Store-event-metachange\" rel=\"Ext.data.Store-event-metachange\" class=\"d