Ext.data.XmlReader.html
11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<div class="body-wrap">
<div class="top-tools">
<a class="inner-link" href="#Ext.data.XmlReader-props"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-prop">Properties</a>
<a class="inner-link" href="#Ext.data.XmlReader-methods"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-method">Methods</a>
<a class="inner-link" href="#Ext.data.XmlReader-events"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-event">Events</a>
<a class="inner-link" href="#Ext.data.XmlReader-configs"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-config">Config Options</a>
<a class="bookmark" href="../docs/?class=Ext.data.XmlReader"><img src="../resources/images/default/s_wev8.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_wev8.gif"/>XmlReader</pre></div>
<h1>Class Ext.data.XmlReader</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"><a href="../source/data/XmlReader_wev8.js" target="_blank">XmlReader_wev8.js</a></td></tr>
<tr><td class="label">Class:</td><td class="hd-info">XmlReader</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 <a ext:cls="Ext.data.Record" href="output/Ext.data.Record.html">Ext.data.Record</a> objects from an XML document
based on mappings in a provided Ext.data.Record constructor.<br><br>
<p>
<em>Note that in order for the browser to parse a returned XML document, the Content-Type
header in the HTTP response must be set to "text/xml".</em>
<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.XmlReader({
totalRecords: <em>"results"</em>, <i>// The element which contains the total dataset size (optional)</i>
record: <em>"row"</em>, <i>// The repeated element which contains row information</i>
id: <em>"id"</em> <i>// The element within the row that provides an ID <b>for</b> the record (optional)</i>
}, Employee);</code></pre>
<p>
This would consume an XML file like this:
<pre><code><?xml?>
<dataset>
<results>2</results>
<row>
<id>1</id>
<name>Bill</name>
<occupation>Gardener</occupation>
</row>
<row>
<id>2</id>
<name>Ben</name>
<occupation>Horticulturalist</occupation>
</row>
</dataset></code></pre> </div>
<div class="hr"></div>
<a id="Ext.data.XmlReader-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.XmlReader-id"></a>
<b>id</b> : String <div class="mdesc">
The DomQuery path relative from the record element to the element that contains a record identifier value. </div>
</td>
<td class="msource">XmlReader</td>
</tr>
<tr class="config-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.XmlReader-record"></a>
<b>record</b> : String <div class="mdesc">
The DomQuery path to the repeated element which contains record information. </div>
</td>
<td class="msource">XmlReader</td>
</tr>
<tr class="config-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.XmlReader-success"></a>
<b>success</b> : String <div class="mdesc">
The DomQuery path to the success attribute used by forms. </div>
</td>
<td class="msource">XmlReader</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.XmlReader-totalRecords"></a>
<b>totalRecords</b> : String <div class="mdesc">
<div class="short">The DomQuery path from which to retrieve the total number of records in the dataset. This is only needed if the whole...</div>
<div class="long">
The DomQuery path 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">XmlReader</td>
</tr>
</table>
<a id="Ext.data.XmlReader-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 inherited">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.XmlReader-meta"></a>
<b>meta</b> : Mixed <div class="mdesc">
This DataReader's configured metadata as passed to the constructor. </div>
</td>
<td class="msource"><a ext:cls="Ext.data.DataReader" ext:member="#meta" href="output/Ext.data.DataReader.html#meta">DataReader</a></td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.XmlReader-xmlData"></a>
<b>xmlData</b> : XMLDocument <div class="mdesc">
After any data loads/reads, the raw XML Document is available for further custom processing. </div>
</td>
<td class="msource">XmlReader</td>
</tr>
</table>
<a id="Ext.data.XmlReader-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.XmlReader-XmlReader"></a>
<b>XmlReader</b>( <code>Object meta</code>, <code>Object recordType</code> ) <div class="mdesc">
<div class="short">Create a new XmlReader.</div>
<div class="long">
Create a new XmlReader. <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 Record constructor object 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">XmlReader</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.XmlReader-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 parsed XML document. The response is expected
to contain a property called <tt>responseXML</tt> which refers to an XML document object.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code><div class="sub-desc">records A data block which is used by an {@link Ext.data.Store} as a cache of Ext.data.Records.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">XmlReader</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.XmlReader-readRecords"></a>
<b>readRecords</b>( <code>Object doc</code> ) : Object <div class="mdesc">
<div class="short">Create a data block containing Ext.data.Records from an XML document.</div>
<div class="long">
Create a data block containing Ext.data.Records from an XML document. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>doc</code> : Object<div class="sub-desc">A parsed XML document.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code><div class="sub-desc">records A data block which is used by an {@link Ext.data.Store} as a cache of Ext.data.Records.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">XmlReader</td>
</tr>
</table>
<a id="Ext.data.XmlReader-events"></a>
<h2>Public Events</h2>
<div class="no-members">This class has no public events.</div>
</div>