b89622238544b838a883869cb630db783c12df83.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <div class="body-wrap">
  2. <div class="top-tools">
  3. <a class="inner-link" href="#Ext.data.Record-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
  4. <a class="inner-link" href="#Ext.data.Record-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
  5. <a class="inner-link" href="#Ext.data.Record-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
  6. <a class="bookmark" href="../docs/?class=Ext.data.Record"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
  7. </div>
  8. <h1>Class Ext.data.Record</h1>
  9. <table cellspacing="0">
  10. <tr><td class="label">Package:</td><td class="hd-info">Ext.data</td></tr>
  11. <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/Record.js" target="_blank">Record.js</a></td></tr>
  12. <tr><td class="label">Class:</td><td class="hd-info">Record</td></tr>
  13. <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
  14. </table>
  15. <div class="description">
  16. Instances of this class encapsulate both record <em>definition</em> information, and record
  17. <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
  18. to access Records cached in an <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> object.<br>
  19. <p>
  20. 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>.
  21. 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
  22. objects.<br>
  23. <p>
  24. Record objects generated by this constructor inherit all the methods of Ext.data.Record listed below. </div>
  25. <div class="hr"></div>
  26. <a id="Ext.data.Record-props"></a>
  27. <h2>Public Properties</h2>
  28. <table cellspacing="0" class="member-table">
  29. <tr>
  30. <th class="sig-header" colspan="2">Property</th>
  31. <th class="msource-header">Defined By</th>
  32. </tr>
  33. <tr class="property-row">
  34. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  35. <td class="sig">
  36. <a id="Ext.data.Record-data"></a>
  37. <b>data</b> : Object <div class="mdesc">
  38. The data for this record an object hash. </div>
  39. </td>
  40. <td class="msource">Record</td>
  41. </tr>
  42. <tr class="property-row alt">
  43. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  44. <td class="sig">
  45. <a id="Ext.data.Record-dirty"></a>
  46. <b>dirty</b> : Boolean <div class="mdesc">
  47. Readonly flag - true if this record has been modified. </div>
  48. </td>
  49. <td class="msource">Record</td>
  50. </tr>
  51. <tr class="property-row">
  52. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  53. <td class="sig">
  54. <a id="Ext.data.Record-id"></a>
  55. <b>id</b> : Object <div class="mdesc">
  56. The unique ID of the record as specified at construction time. </div>
  57. </td>
  58. <td class="msource">Record</td>
  59. </tr>
  60. <tr class="property-row alt expandable">
  61. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  62. <td class="sig">
  63. <a id="Ext.data.Record-modified"></a>
  64. <b>modified</b> : Object <div class="mdesc">
  65. <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>
  66. <div class="long">
  67. 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>
  68. </div>
  69. </td>
  70. <td class="msource">Record</td>
  71. </tr>
  72. </table>
  73. <a id="Ext.data.Record-methods"></a>
  74. <h2>Public Methods</h2>
  75. <table cellspacing="0" class="member-table">
  76. <tr>
  77. <th class="sig-header" colspan="2">Method</th>
  78. <th class="msource-header">Defined By</th>
  79. </tr>
  80. <tr class="method-row expandable">
  81. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  82. <td class="sig">
  83. <a id="Ext.data.Record-Record"></a>
  84. <b>Record</b>(&nbsp;<code>Array data</code>, <span class="optional" title="Optional">[<code>Object id</code>]</span>&nbsp;) <div class="mdesc">
  85. <div class="short">This constructor should not be used to create Record objects. Instead, use the constructor generated by
  86. create. The p...</div>
  87. <div class="long">
  88. This constructor should not be used to create Record objects. Instead, use the constructor generated by
  89. <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">
  90. <strong>Parameters:</strong>
  91. <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
  92. <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
  93. not specified an integer id is generated.</div></li> </ul>
  94. <strong>Returns:</strong>
  95. <ul>
  96. <li><code></code></li>
  97. </ul>
  98. </div>
  99. </div>
  100. </div>
  101. </td>
  102. <td class="msource">Record</td>
  103. </tr>
  104. <tr class="method-row alt expandable">
  105. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  106. <td class="sig">
  107. <a id="Ext.data.Record-beginEdit"></a>
  108. <b>beginEdit</b>() : void <div class="mdesc">
  109. <div class="short">Begin an edit. While in edit mode, no events are relayed to the containing store.</div>
  110. <div class="long">
  111. Begin an edit. While in edit mode, no events are relayed to the containing store. <div class="mdetail-params">
  112. <strong>Parameters:</strong>
  113. <ul><li>None.</li> </ul>
  114. <strong>Returns:</strong>
  115. <ul>
  116. <li><code>void</code></li>
  117. </ul>
  118. </div>
  119. </div>
  120. </div>
  121. </td>
  122. <td class="msource">Record</td>
  123. </tr>
  124. <tr class="method-row expandable">
  125. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  126. <td class="sig">
  127. <a id="Ext.data.Record-cancelEdit"></a>
  128. <b>cancelEdit</b>() : void <div class="mdesc">
  129. <div class="short">Cancels all changes made in the current edit operation.</div>
  130. <div class="long">
  131. Cancels all changes made in the current edit operation. <div class="mdetail-params">
  132. <strong>Parameters:</strong>
  133. <ul><li>None.</li> </ul>
  134. <strong>Returns:</strong>
  135. <ul>
  136. <li><code>void</code></li>
  137. </ul>
  138. </div>
  139. </div>
  140. </div>
  141. </td>
  142. <td class="msource">Record</td>
  143. </tr>
  144. <tr class="method-row alt expandable">
  145. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  146. <td class="sig">
  147. <a id="Ext.data.Record-commit"></a>
  148. <b>commit</b>(&nbsp;<span class="optional" title="Optional">[<code>Boolean silent</code>]</span>&nbsp;) : void <div class="mdesc">
  149. <div class="short">Usually called by the Ext.data.Store which owns the Record.
  150. Commits all changes made to the Record since either creat...</div>
  151. <div class="long">
  152. Usually called by the <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> which owns the Record.
  153. Commits all changes made to the Record since either creation, or the last commit operation.
  154. <p>
  155. 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
  156. of commit operations. <div class="mdetail-params">
  157. <strong>Parameters:</strong>
  158. <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>
  159. <strong>Returns:</strong>
  160. <ul>
  161. <li><code>void</code></li>
  162. </ul>
  163. </div>
  164. </div>
  165. </div>
  166. </td>
  167. <td class="msource">Record</td>
  168. </tr>
  169. <tr class="method-row expandable">
  170. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  171. <td class="sig">
  172. <a id="Ext.data.Record-copy"></a>
  173. <b>copy</b>(&nbsp;<span class="optional" title="Optional">[<code>String id</code>]</span>&nbsp;) : Record <div class="mdesc">
  174. <div class="short">Creates a copy of this record.</div>
  175. <div class="long">
  176. Creates a copy of this record. <div class="mdetail-params">
  177. <strong>Parameters:</strong>
  178. <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>
  179. <strong>Returns:</strong>
  180. <ul>
  181. <li><code>Record</code></li>
  182. </ul>
  183. </div>
  184. </div>
  185. </div>
  186. </td>
  187. <td class="msource">Record</td>
  188. </tr>
  189. <tr class="method-row alt expandable">
  190. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  191. <td class="sig">
  192. <a id="Ext.data.Record-create"></a>
  193. <b>create</b>(&nbsp;<span class="optional" title="Optional">[<code>Array o</code>]</span>&nbsp;) : function <div class="mdesc">
  194. <div class="short">&lt;static&gt; Generate a constructor for a specific record layout.</div>
  195. <div class="long">
  196. &lt;static&gt; Generate a constructor for a specific record layout. <div class="mdetail-params">
  197. <strong>Parameters:</strong>
  198. <ul><li><code>o</code> : Array<div class="sub-desc">An Array of field definition objects which specify field names, and optionally,
  199. 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.
  200. Each field definition object may contain the following properties: <ul>
  201. <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,
  202. 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>
  203. <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
  204. 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>
  205. is being used, then this is a string containing the javascript expression to reference the data relative to
  206. 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
  207. to the data item relative to the record element. If the mapping expression is the same as the field name,
  208. this may be omitted.</p></li>
  209. <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
  210. <ul><li>auto (Default, implies no conversion)</li>
  211. <li>string</li>
  212. <li>int</li>
  213. <li>float</li>
  214. <li>boolean</li>
  215. <li>date</li></ul></p></li>
  216. <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>
  217. <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
  218. <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
  219. by the Reader into an object that will be stored in the Record. It is passed the
  220. following parameters:<ul>
  221. <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
  222. </ul></p></li>
  223. <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
  224. </ul>
  225. <br>usage:<br><pre><code>var TopicRecord = Ext.data.Record.create([
  226. {name: <em>'title'</em>, mapping: <em>'topic_title'</em>},
  227. {name: <em>'author'</em>, mapping: <em>'username'</em>},
  228. {name: <em>'totalPosts'</em>, mapping: <em>'topic_replies'</em>, type: <em>'int'</em>},
  229. {name: <em>'lastPost'</em>, mapping: <em>'post_time'</em>, type: <em>'date'</em>},
  230. {name: <em>'lastPoster'</em>, mapping: <em>'user2'</em>},
  231. {name: <em>'excerpt'</em>, mapping: <em>'post_text'</em>}
  232. ]);
  233. <b>var</b> myNewRecord = <b>new</b> TopicRecord({
  234. title: <em>'Do my job please'</em>,
  235. author: <em>'noobie'</em>,
  236. totalPosts: 1,
  237. lastPost: <b>new</b> Date(),
  238. lastPoster: <em>'Animal'</em>,
  239. excerpt: <em>'No way dude!'</em>
  240. });
  241. myStore.add(myNewRecord);</code></pre>
  242. <p>In the simplest case, if no properties other than <tt>name</tt> are required, a field definition
  243. may consist of just a field name string.</p></div></li> </ul>
  244. <strong>Returns:</strong>
  245. <ul>
  246. <li><code>function</code><div class="sub-desc">A constructor which is used to create new Records according to the definition.</div></li>
  247. </ul>
  248. </div>
  249. </div>
  250. </div>
  251. </td>
  252. <td class="msource">Record</td>
  253. </tr>
  254. <tr class="method-row expandable">
  255. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  256. <td class="sig">
  257. <a id="Ext.data.Record-endEdit"></a>
  258. <b>endEdit</b>() : void <div class="mdesc">
  259. <div class="short">End an edit. If any data was modified, the containing store is notified.</div>
  260. <div class="long">
  261. End an edit. If any data was modified, the containing store is notified. <div class="mdetail-params">
  262. <strong>Parameters:</strong>
  263. <ul><li>None.</li> </ul>
  264. <strong>Returns:</strong>
  265. <ul>
  266. <li><code>void</code></li>
  267. </ul>
  268. </div>
  269. </div>
  270. </div>
  271. </td>
  272. <td class="msource">Record</td>
  273. </tr>
  274. <tr class="method-row alt expandable">
  275. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  276. <td class="sig">
  277. <a id="Ext.data.Record-get"></a>
  278. <b>get</b>(&nbsp;<code>String name</code>&nbsp;) : Object <div class="mdesc">
  279. <div class="short">Get the value of the named field.</div>
  280. <div class="long">
  281. Get the value of the named field. <div class="mdetail-params">
  282. <strong>Parameters:</strong>
  283. <ul><li><code>name</code> : String<div class="sub-desc">The name of the field to get the value of.</div></li> </ul>
  284. <strong>Returns:</strong>
  285. <ul>
  286. <li><code>Object</code><div class="sub-desc">The value of the field.</div></li>
  287. </ul>
  288. </div>
  289. </div>
  290. </div>
  291. </td>
  292. <td class="msource">Record</td>
  293. </tr>
  294. <tr class="method-row expandable">
  295. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  296. <td class="sig">
  297. <a id="Ext.data.Record-getChanges"></a>
  298. <b>getChanges</b>() : Object <div class="mdesc">
  299. <div class="short">Gets a hash of only the fields that have been modified since this record was created or commited.</div>
  300. <div class="long">
  301. Gets a hash of only the fields that have been modified since this record was created or commited. <div class="mdetail-params">
  302. <strong>Parameters:</strong>
  303. <ul><li>None.</li> </ul>
  304. <strong>Returns:</strong>
  305. <ul>
  306. <li><code>Object</code></li>
  307. </ul>
  308. </div>
  309. </div>
  310. </div>
  311. </td>
  312. <td class="msource">Record</td>
  313. </tr>
  314. <tr class="method-row alt expandable">
  315. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  316. <td class="sig">
  317. <a id="Ext.data.Record-reject"></a>
  318. <b>reject</b>(&nbsp;<span class="optional" title="Optional">[<code>Boolean silent</code>]</span>&nbsp;) : void <div class="mdesc">
  319. <div class="short">Usually called by the Ext.data.Store which owns the Record.
  320. Rejects all changes made to the Record since either creat...</div>
  321. <div class="long">
  322. Usually called by the <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Ext.data.Store</a> which owns the Record.
  323. Rejects all changes made to the Record since either creation, or the last commit operation.
  324. Modified fields are reverted to their original values.
  325. <p>
  326. 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
  327. of reject operations. <div class="mdetail-params">
  328. <strong>Parameters:</strong>
  329. <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>
  330. <strong>Returns:</strong>
  331. <ul>
  332. <li><code>void</code></li>
  333. </ul>
  334. </div>
  335. </div>
  336. </div>
  337. </td>
  338. <td class="msource">Record</td>
  339. </tr>
  340. <tr class="method-row expandable">
  341. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  342. <td class="sig">
  343. <a id="Ext.data.Record-set"></a>
  344. <b>set</b>(&nbsp;<code>String name</code>, <code>Object value</code>&nbsp;) : void <div class="mdesc">
  345. <div class="short">Set the named field to the specified value.</div>
  346. <div class="long">
  347. Set the named field to the specified value. <div class="mdetail-params">
  348. <strong>Parameters:</strong>
  349. <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>
  350. <strong>Returns:</strong>
  351. <ul>
  352. <li><code>void</code></li>
  353. </ul>
  354. </div>
  355. </div>
  356. </div>
  357. </td>
  358. <td class="msource">Record</td>
  359. </tr>
  360. </table>
  361. <a id="Ext.data.Record-events"></a>
  362. <h2>Public Events</h2>
  363. <div class="no-members">This class has no public events.</div>
  364. </div>