📄 ext.data.jsonreader.html.svn-base
字号:
<div class="body-wrap"> <div class="top-tools"> <a class="inner-link" href="#Ext.data.JsonReader-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a> <a class="inner-link" href="#Ext.data.JsonReader-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a> <a class="inner-link" href="#Ext.data.JsonReader-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a> <a class="inner-link" href="#Ext.data.JsonReader-configs"><img src="../resources/images/default/s.gif" class="item-icon icon-config">Config Options</a> <a class="bookmark" href="../docs/?class=Ext.data.JsonReader"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a> </div> <div class="inheritance res-block"><pre class="res-block-inner"><a ext:cls="Ext.data.DataReader" ext:member="" href="output/Ext.data.DataReader.html">DataReader</a> <img src="resources/elbow-end.gif"/>JsonReader</pre></div> <h1>Class Ext.data.JsonReader</h1> <table cellspacing="0"> <tr><td class="label">Package:</td><td class="hd-info">Ext.data</td></tr> <tr><td class="label">Defined In:</td><td class="hd-info">JsonReader.js</td></tr> <tr><td class="label">Class:</td><td class="hd-info">JsonReader</td></tr> <tr><td class="label">Subclasses:</td><td class="hd-info"><a ext:cls="Ext.data.ArrayReader" href="output/Ext.data.ArrayReader.html">ArrayReader</a></td></tr> <tr><td class="label">Extends:</td><td class="hd-info"><a ext:cls="Ext.data.DataReader" ext:member="" href="output/Ext.data.DataReader.html">DataReader</a></td></tr> </table> <div class="description"> Data reader class to create an Array of Ext.data.Record objects from a JSON responsebased on mappings in a provided Ext.data.Record constructor.<br><p>Example code:<pre><code>var Employee = Ext.data.Record.create([ {name: <em>'name'</em>, mapping: <em>'name'</em>}, <i>// <em>"mapping"</em> property not needed <b>if</b> it's the same as <em>"name"</em></i> {name: <em>'occupation'</em>} <i>// This field will use <em>"occupation"</em> as the mapping.</i>]);<b>var</b> myReader = <b>new</b> Ext.data.JsonReader({ totalProperty: <em>"results"</em>, <i>// The property which contains the total dataset size (optional)</i> root: <em>"rows"</em>, <i>// The property which contains an Array of row objects</i> id: <em>"id"</em> <i>// The property within each row object that provides an ID <b>for</b> the record (optional)</i>}, Employee);</code></pre><p>This would consume a JSON file like this:<pre><code>{ <em>'results'</em>: 2, <em>'rows'</em>: [ { <em>'id'</em>: 1, <em>'name'</em>: <em>'Bill'</em>, occupation: <em>'Gardener'</em> }, { <em>'id'</em>: 2, <em>'name'</em>: <em>'Ben'</em>, occupation: <em>'Horticulturalist'</em> } ]}</code></pre><p>It is possible to change a JsonReader's metadata at any time by including a<b><tt>MetaData</tt></b> property in the data object. If this is detected in theobject, a <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Store</a> object using this Reader will fire its<a ext:cls="Ext.data.Store" ext:member="metachange" href="output/Ext.data.Store.html#metachange">metachange</a> event.</p><p>The <b><tt>MetaData</tt></b> property may contain any of the configurationoptions for this class. Additionally, it may contain a <b><tt>fields</tt></b>property which the JsonReader will use as an argument to <a ext:cls="Ext.data.Record.create" href="output/Ext.data.Record.create.html">Ext.data.Record.create</a>to configure the layout of the Records which it will produce.<p>Using the <b><tt>MetaData</tt></b> property, and the Store's <a ext:cls="Ext.data.Store" ext:member="metachange" href="output/Ext.data.Store.html#metachange">metachange</a> event,it is possible to have a Store-driven control initialize itself. The metachangeevent handler may interrogate the <b><tt>MetaData</tt></b> property (whichmay contain any user-defined properties needed) and the <b><tt>MetaData.fields</tt></b>property to perform any configuration required.</p><p>To use this facility to send the same data as the above example withouthaving to code the creation of the Record constructor, you would create theJsonReader like this:</p><pre><code>var myReader = <b>new</b> Ext.data.JsonReader();</code></pre><p>The first data packet from the server would configure the reader bycontaining a metaData property as well as the data:</p><pre><code>{ <em>'metaData'</em>: { totalProperty: <em>'results'</em>, root: <em>'rows'</em>, id: <em>'id'</em>, fields: [ {name: <em>'name'</em>}, {name: <em>'occupation'</em>} ] }, <em>'results'</em>: 2, <em>'rows'</em>: [ { <em>'id'</em>: 1, <em>'name'</em>: <em>'Bill'</em>, occupation: <em>'Gardener'</em> }, { <em>'id'</em>: 2, <em>'name'</em>: <em>'Ben'</em>, occupation: <em>'Horticulturalist'</em> } ]}</code></pre> </div> <div class="hr"></div> <a id="Ext.data.JsonReader-configs"></a> <h2>Config Options</h2> <table cellspacing="0" class="member-table"> <tr> <th class="sig-header" colspan="2">Config Options</th> <th class="msource-header">Defined By</th> </tr> <tr class="config-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-id"></a>
<b>id</b> : String <div class="mdesc">
Name of the property within a row object that contains a record identifier value. </div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="config-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-root"></a>
<b>root</b> : String <div class="mdesc">
name of the property which contains the Array of row objects. </div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="config-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-successProperty"></a>
<b>successProperty</b> : String <div class="mdesc">
Name of the property from which to retrieve the success attribute used by forms. </div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="config-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-totalProperty"></a>
<b>totalProperty</b> : String <div class="mdesc">
<div class="short">Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the wh...</div>
<div class="long">
Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the whole dataset is not passed in one go, but is being paged from the remote server. </div>
</div>
</td>
<td class="msource">JsonReader</td>
</tr>
</table> <a id="Ext.data.JsonReader-props"></a> <h2>Public Properties</h2> <table cellspacing="0" class="member-table"> <tr> <th class="sig-header" colspan="2">Property</th> <th class="msource-header">Defined By</th> </tr> <tr class="property-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-jsonData"></a>
<b>jsonData</b> : Object <div class="mdesc">
<div class="short">After any data loads, the raw JSON data is available for further custom processing. If no data isloaded or there is...</div>
<div class="long">
After any data loads, the raw JSON data is available for further custom processing. If no data isloaded or there is a load exception this property will be undefined. </div>
</div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-meta"></a>
<b>meta</b> : Mixed <div class="mdesc">
This JsonReader's metadata as passed to the constructor, or as passed inthe last data packet's <b><tt>MetaData</tt></b> property. </div>
</td>
<td class="msource">JsonReader</td>
</tr>
</table> <a id="Ext.data.JsonReader-methods"></a> <h2>Public Methods</h2> <table cellspacing="0" class="member-table"> <tr> <th class="sig-header" colspan="2">Method</th> <th class="msource-header">Defined By</th> </tr> <tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-JsonReader"></a>
<b>JsonReader</b>( <code>Object meta</code>, <code>Object recordType</code> ) <div class="mdesc">
<div class="short">Create a new JsonReader</div>
<div class="long">
Create a new JsonReader <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>meta</code> : Object<div class="sub-desc">Metadata configuration options.</div></li><li><code>recordType</code> : Object<div class="sub-desc">Either an Array of field definition objects as passed to<a ext:cls="Ext.data.Record" ext:member="create" href="output/Ext.data.Record.html#create">Ext.data.Record.create</a>, or a <a ext:cls="Ext.data.Record" href="output/Ext.data.Record.html">Record</a> constructor created using <a ext:cls="Ext.data.Record" ext:member="create" href="output/Ext.data.Record.html#create">Ext.data.Record.create</a>.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code></code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="method-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-read"></a>
<b>read</b>( <code>Object response</code> ) : Object <div class="mdesc">
<div class="short">This method is only used by a DataProxy which has retrieved data from a remote server.</div>
<div class="long">
This method is only used by a DataProxy which has retrieved data from a remote server. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>response</code> : Object<div class="sub-desc">The XHR object which contains the JSON data in its responseText.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code><div class="sub-desc">data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">JsonReader</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.JsonReader-readRecords"></a>
<b>readRecords</b>( <code>Object o</code> ) : Object <div class="mdesc">
<div class="short">Create a data block containing Ext.data.Records from a JSON object.</div>
<div class="long">
Create a data block containing Ext.data.Records from a JSON object. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>o</code> : Object<div class="sub-desc">An object which contains an Array of row objects in the property specifiedin the config as 'root, and optionally a property, specified in the config as 'totalProperty'which contains the total size of the dataset.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code><div class="sub-desc">data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">JsonReader</td>
</tr>
</table> <a id="Ext.data.JsonReader-events"></a> <h2>Public Events</h2> <div class="no-members">This class has no public events.</div> </div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -