Ext.data.Record.html
21 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<div class="body-wrap">
<div class="top-tools">
<a class="inner-link" href="#Ext.data.Record-props"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-prop">Properties</a>
<a class="inner-link" href="#Ext.data.Record-methods"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-method">Methods</a>
<a class="inner-link" href="#Ext.data.Record-events"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-event">Events</a>
<a class="bookmark" href="../docs/?class=Ext.data.Record"><img src="../resources/images/default/s_wev8.gif" class="item-icon icon-fav">Direct Link</a>
</div>
<h1>Class Ext.data.Record</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/Record_wev8.js" target="_blank">Record_wev8.js</a></td></tr>
<tr><td class="label">Class:</td><td class="hd-info">Record</td></tr>
<tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
</table>
<div class="description">
Instances of this class encapsulate both record <em>definition</em> information, and record
<em>value</em> information for use in <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> objects, or any code which needs
to access Records cached in an <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> object.<br>
<p>
Constructors for this class are generated by passing an Array of field definition objects to <a ext:cls="Ext.data.Record" ext:member="create" href="output/Ext.data.Record.html#create">create</a>.
Instances are usually only created by <a ext:cls="Ext.data.Reader" href="output/Ext.data.Reader.html">Ext.data.Reader</a> implementations when processing unformatted data
objects.<br>
<p>
Record objects generated by this constructor inherit all the methods of Ext.data.Record listed below. </div>
<div class="hr"></div>
<a id="Ext.data.Record-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">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-data"></a>
<b>data</b> : Object <div class="mdesc">
The data for this record an object hash. </div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-dirty"></a>
<b>dirty</b> : Boolean <div class="mdesc">
Readonly flag - true if this record has been modified. </div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-id"></a>
<b>id</b> : Object <div class="mdesc">
The unique ID of the record as specified at construction time. </div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="property-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-modified"></a>
<b>modified</b> : Object <div class="mdesc">
<div class="short">This object contains a key and value storing the original values of all modified fields or is null if no fields have ...</div>
<div class="long">
This object contains a key and value storing the original values of all modified fields or is null if no fields have been modified. </div>
</div>
</td>
<td class="msource">Record</td>
</tr>
</table>
<a id="Ext.data.Record-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.Record-Record"></a>
<b>Record</b>( <code>Array data</code>, <span class="optional" title="Optional">[<code>Object id</code>]</span> ) <div class="mdesc">
<div class="short">This constructor should not be used to create Record objects. Instead, use the constructor generated by
create. The p...</div>
<div class="long">
This constructor should not be used to create Record objects. Instead, use the constructor generated by
<a ext:cls="Ext.data.Record" ext:member="create" href="output/Ext.data.Record.html#create">create</a>. The parameters are the same. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>data</code> : Array<div class="sub-desc">An associative Array of data values keyed by the field name.</div></li><li><code>id</code> : Object<div class="sub-desc">(Optional) The id of the record. This id should be unique, and is used by the
<a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> object which owns the Record to index its collection of Records. If
not specified an integer id is generated.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code></code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-beginEdit"></a>
<b>beginEdit</b>() : void <div class="mdesc">
<div class="short">Begin an edit. While in edit mode, no events are relayed to the containing store.</div>
<div class="long">
Begin an edit. While in edit mode, no events are relayed to the containing store. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-cancelEdit"></a>
<b>cancelEdit</b>() : void <div class="mdesc">
<div class="short">Cancels all changes made in the current edit operation.</div>
<div class="long">
Cancels all changes made in the current edit operation. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-commit"></a>
<b>commit</b>( <span class="optional" title="Optional">[<code>Boolean silent</code>]</span> ) : void <div class="mdesc">
<div class="short">Usually called by the Ext.data.Store which owns the Record.
Commits all changes made to the Record since either creat...</div>
<div class="long">
Usually called by the <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> which owns the Record.
Commits all changes made to the Record since either creation, or the last commit operation.
<p>
Developers should subscribe to the <a ext:cls="Ext.data.Store" ext:member="update" href="output/Ext.data.Store.html#update">Ext.data.Store.update</a> event to have their code notified
of commit operations. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>silent</code> : Boolean<div class="sub-desc">(optional) True to skip notification of the owning store of the change (defaults to false)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-copy"></a>
<b>copy</b>( <span class="optional" title="Optional">[<code>String id</code>]</span> ) : Record <div class="mdesc">
<div class="short">Creates a copy of this record.</div>
<div class="long">
Creates a copy of this record. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>id</code> : String<div class="sub-desc">(optional) A new record id if you don't want to use this record's id</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Record</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-create"></a>
<b>create</b>( <span class="optional" title="Optional">[<code>Array o</code>]</span> ) : function <div class="mdesc">
<div class="short"><static> Generate a constructor for a specific record layout.</div>
<div class="long">
<static> Generate a constructor for a specific record layout. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>o</code> : Array<div class="sub-desc">An Array of field definition objects which specify field names, and optionally,
data types, and a mapping for an <a ext:cls="Ext.data.Reader" href="output/Ext.data.Reader.html">Ext.data.Reader</a> to extract the field's value from a data object.
Each field definition object may contain the following properties: <ul>
<li><b>name</b> : String<p style="margin-left:1em">The name by which the field is referenced within the Record. This is referenced by,
for example the <em>dataIndex</em> property in column definition objects passed to <a ext:cls="Ext.grid.ColumnModel" href="output/Ext.grid.ColumnModel.html">Ext.grid.ColumnModel</a></p></li>
<li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the <a ext:cls="Ext.data.Reader" href="output/Ext.data.Reader.html">Ext.data.Reader</a> implementation
that is creating the Record to access the data value from the data object. If an <a ext:cls="Ext.data.JsonReader" href="output/Ext.data.JsonReader.html">Ext.data.JsonReader</a>
is being used, then this is a string containing the javascript expression to reference the data relative to
the record item's root. If an <a ext:cls="Ext.data.XmlReader" href="output/Ext.data.XmlReader.html">Ext.data.XmlReader</a> is being used, this is an <a ext:cls="Ext.DomQuery" href="output/Ext.DomQuery.html">Ext.DomQuery</a> path
to the data item relative to the record element. If the mapping expression is the same as the field name,
this may be omitted.</p></li>
<li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
<ul><li>auto (Default, implies no conversion)</li>
<li>string</li>
<li>int</li>
<li>float</li>
<li>boolean</li>
<li>date</li></ul></p></li>
<li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of <a ext:cls="Ext.data.SortTypes" href="output/Ext.data.SortTypes.html">Ext.data.SortTypes</a>.</p></li>
<li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
<li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
by the Reader into an object that will be stored in the Record. It is passed the
following parameters:<ul>
<li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
<li><b>rec</b> : Mixed<p style="margin-left:1em">The data object containting the row as read by the Reader.
Depending on Reader type, this could be an Array, an object, or an XML element.</p></li>
</ul></p></li>
<li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
</ul>
<br>usage:<br><pre><code>var TopicRecord = Ext.data.Record.create([
{name: <em>'title'</em>, mapping: <em>'topic_title'</em>},
{name: <em>'author'</em>, mapping: <em>'username'</em>},
{name: <em>'totalPosts'</em>, mapping: <em>'topic_replies'</em>, type: <em>'int'</em>},
{name: <em>'lastPost'</em>, mapping: <em>'post_time'</em>, type: <em>'date'</em>},
{name: <em>'lastPoster'</em>, mapping: <em>'user2'</em>},
{name: <em>'excerpt'</em>, mapping: <em>'post_text'</em>}
]);
<b>var</b> myNewRecord = <b>new</b> TopicRecord({
title: <em>'Do my job please'</em>,
author: <em>'noobie'</em>,
totalPosts: 1,
lastPost: <b>new</b> Date(),
lastPoster: <em>'Animal'</em>,
excerpt: <em>'No way dude!'</em>
});
myStore.add(myNewRecord);</code></pre>
<p>In the simplest case, if no properties other than <tt>name</tt> are required, a field definition
may consist of just a field name string.</p></div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>function</code><div class="sub-desc">A constructor which is used to create new Records according to the definition.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-endEdit"></a>
<b>endEdit</b>() : void <div class="mdesc">
<div class="short">End an edit. If any data was modified, the containing store is notified.</div>
<div class="long">
End an edit. If any data was modified, the containing store is notified. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-get"></a>
<b>get</b>( <code>String name</code> ) : Object <div class="mdesc">
<div class="short">Get the value of the named field.</div>
<div class="long">
Get the value of the named field. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>name</code> : String<div class="sub-desc">The name of the field to get the value of.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code><div class="sub-desc">The value of the field.</div></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-getChanges"></a>
<b>getChanges</b>() : Object <div class="mdesc">
<div class="short">Gets a hash of only the fields that have been modified since this record was created or commited.</div>
<div class="long">
Gets a hash of only the fields that have been modified since this record was created or commited. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li>None.</li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Object</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-isModified"></a>
<b>isModified</b>( <code>String fieldName</code> ) : Boolean <div class="mdesc">
<div class="short">Returns true if the field passed has been modified since the load or last commit.</div>
<div class="long">
Returns true if the field passed has been modified since the load or last commit. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>fieldName</code> : String<div class="sub-desc"></div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>Boolean</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
<tr class="method-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Ext.data.Record-reject"></a>
<b>reject</b>( <span class="optional" title="Optional">[<code>Boolean silent</code>]</span> ) : void <div class="mdesc">
<div class="short">Usually called by the Ext.data.Store which owns the Record.
Rejects all changes made to the Record since either creat...</div>
<div class="long">
Usually called by the <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> which owns the Record.
Rejects all changes made to the Record since either creation, or the last commit operation.
Modified fields are reverted to their original values.
<p>
Developers should subscribe to the <a ext:cls="Ext.data.Store" ext:member="update" href="output/Ext.data.Store.html#update">Ext.data.Store.update</a> event to have their code notified
of reject operations. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>silent</code> : Boolean<div class="sub-desc">(optional) True to skip notification of the owning store of the change (defaults to false)</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</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.Record-set"></a>
<b>set</b>( <code>String name</code>, <code>Object value</code> ) : void <div class="mdesc">
<div class="short">Set the named field to the specified value.</div>
<div class="long">
Set the named field to the specified value. <div class="mdetail-params">
<strong>Parameters:</strong>
<ul><li><code>name</code> : String<div class="sub-desc">The name of the field to set.</div></li><li><code>value</code> : Object<div class="sub-desc">The value to set the field to.</div></li> </ul>
<strong>Returns:</strong>
<ul>
<li><code>void</code></li>
</ul>
</div>
</div>
</div>
</td>
<td class="msource">Record</td>
</tr>
</table>
<a id="Ext.data.Record-events"></a>
<h2>Public Events</h2>
<div class="no-members">This class has no public events.</div>
</div>