Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.data.Types.html
1 <!DOCTYPE html><html><head><title>Ext.data.Types | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.data.Types',
13         docClass: 'Ext.data.Types',
14         docReq: 'Ext.data.Types',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'Types.html#Ext-data.Types';
33     clsInfo = {"methods":[],"cfgs":[],"properties":["AUTO","BOOL","BOOLEAN","DATE","FLOAT","INT","INTEGER","NUMBER","STRING","stripRe"],"events":[],"subclasses":[]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Types.html#Ext-data.Types" target="_blank">Ext.data.Types</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>This is s static class containing the system-supplied data types which may be given to a <a href="Ext.data.Field.html" rel="Ext.data.Field" class="docClass">Field</a>.<p/>
38 <p>The properties in this class are used as type indicators in the <a href="Ext.data.Field.html" rel="Ext.data.Field" class="docClass">Field</a> class, so to
39 test whether a Field is of a certain type, compare the <a href="Ext.data.Field.html#type" rel="Ext.data.Field#type" class="docClass">type</a> property against properties
40 of this class.</p>
41 <p>Developers may add their own application-specific data types to this class. Definition names must be UPPERCASE.
42 each type definition must contain three properties:</p>
43 <div class="mdetail-params"><ul>
44 <li><code>convert</code> : <i>Function</i><div class="sub-desc">A function to convert raw data values from a data block into the data
45 to be stored in the Field. The function is passed the collowing parameters:
46 <div class="mdetail-params"><ul>
47 <li><b>v</b> : Mixed<div class="sub-desc">The data value as read by the Reader, if undefined will use
48 the configured <tt><a href="Ext.data.Field.html#defaultValue" rel="Ext.data.Field#defaultValue" class="docClass">defaultValue</a></tt>.</div></li>
49 <li><b>rec</b> : Mixed<div class="sub-desc">The data object containing the row as read by the Reader.
50 Depending on the Reader type, this could be an Array (<a href="Ext.data.reader.Array.html" rel="Ext.data.reader.Array" class="docClass">ArrayReader</a>), an object
51 (<a href="Ext.data.reader.Json.html" rel="Ext.data.reader.Json" class="docClass">JsonReader</a>), or an XML element.</div></li>
52 </ul></div></div></li>
53 <li><code>sortType</code> : <i>Function</i> <div class="sub-desc">A function to convert the stored data into comparable form, as defined by <a href="Ext.data.SortTypes.html" rel="Ext.data.SortTypes" class="docClass">Ext.data.SortTypes</a>.</div></li>
54 <li><code>type</code> : <i>String</i> <div class="sub-desc">A textual data type name.</div></li>
55 </ul></div>
56 <p>For example, to create a VELatLong field (See the Microsoft Bing Mapping API) containing the latitude/longitude value of a datapoint on a map from a JsonReader data block
57 which contained the properties <code>lat</code> and <code>long</code>, you would define a new data type like this:</p>
58 <pre class="prettyprint"><code>// Add a new Field data type which stores a VELatLong object in the Record.
59 Ext.data.Types.VELATLONG = {
60     convert: function(v, data) {
61         return new VELatLong(data.lat, data.long);
62     },
63     sortType: function(v) {
64         return v.Latitude;  // When sorting, order by latitude
65     },
66     type: 'VELatLong'
67 };
68 </code></pre>
69 <p>Then, when declaring a Model, use 
70 <pre class="prettyprint"><code>var types = Ext.data.Types; // allow shorthand type access
71 Ext.define('Unit',
72     extend: 'Ext.data.Model', 
73     fields: [
74         { name: 'unitName', mapping: 'UnitName' },
75         { name: 'curSpeed', mapping: 'CurSpeed', type: types.INT },
76         { name: 'latitude', mapping: 'lat', type: types.FLOAT },
77         { name: 'latitude', mapping: 'lat', type: types.FLOAT },
78         { name: 'position', type: types.VELATLONG }
79     ]
80 });
81 </code></pre>
82
83 <div class="members"><div class="m-properties"><a name="properties"></a><div class="definedBy">Defined By</div><h3 class="prp p">Properties</h3><div id="property-AUTO" class="member f ni"><a href="Ext.data.Types.html#property-AUTO" rel="property-AUTO" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-AUTO" class="viewSource">view source</a></div><a name="AUTO"></a><a name="property-AUTO"></a><a href="Ext.data.Types.html#" rel="property-AUTO" class="cls expand">AUTO</a><span> : Object.</span></div><div class="description"><div class="short"><p>This data type means that no conversion is applied to the raw data before it is placed into a Record.</p>
84 </div><div class="long"><p>This data type means that no conversion is applied to the raw data before it is placed into a Record.</p>
85 </div></div></div><div id="property-BOOL" class="member ni"><a href="Ext.data.Types.html#property-BOOL" rel="property-BOOL" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-BOOL" class="viewSource">view source</a></div><a name="BOOL"></a><a name="property-BOOL"></a><a href="Ext.data.Types.html#" rel="property-BOOL" class="cls expand">BOOL</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into a boolean before it is placed into
86 a Record. The string "tru...</div><div class="long"><p>This data type means that the raw data is converted into a boolean before it is placed into
87 a Record. The string "true" and the number 1 are converted to boolean <code>true</code>.</p>
88
89
90 <p>The synonym <code>BOOLEAN</code> is equivalent.</p>
91
92 </div></div></div><div id="property-BOOLEAN" class="member ni"><a href="Ext.data.Types.html#property-BOOLEAN" rel="property-BOOLEAN" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-BOOLEAN" class="viewSource">view source</a></div><a name="BOOLEAN"></a><a name="property-BOOLEAN"></a><a href="Ext.data.Types.html#" rel="property-BOOLEAN" class="cls expand">BOOLEAN</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into a boolean before it is placed into
93 a Record. The string "tru...</div><div class="long"><p>This data type means that the raw data is converted into a boolean before it is placed into
94 a Record. The string "true" and the number 1 are converted to boolean <code>true</code>.</p>
95
96
97 <p>The synonym <code>BOOL</code> is equivalent.</p>
98
99 </div></div></div><div id="property-DATE" class="member ni"><a href="Ext.data.Types.html#property-DATE" rel="property-DATE" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-DATE" class="viewSource">view source</a></div><a name="DATE"></a><a name="property-DATE"></a><a href="Ext.data.Types.html#" rel="property-DATE" class="cls expand">DATE</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into a Date before it is placed into a Record.
100 The date format is...</div><div class="long"><p>This data type means that the raw data is converted into a Date before it is placed into a Record.
101 The date format is specified in the constructor of the <a href="Ext.data.Field.html" rel="Ext.data.Field" class="docClass">Ext.data.Field</a> to which this type is
102 being applied.</p>
103 </div></div></div><div id="property-FLOAT" class="member ni"><a href="Ext.data.Types.html#property-FLOAT" rel="property-FLOAT" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-FLOAT" class="viewSource">view source</a></div><a name="FLOAT"></a><a name="property-FLOAT"></a><a href="Ext.data.Types.html#" rel="property-FLOAT" class="cls expand">FLOAT</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into a number before it is placed into a Record.
104
105 The synonym NUM...</div><div class="long"><p>This data type means that the raw data is converted into a number before it is placed into a Record.</p>
106
107 <p>The synonym <code>NUMBER</code> is equivalent.</p>
108
109 </div></div></div><div id="property-INT" class="member ni"><a href="Ext.data.Types.html#property-INT" rel="property-INT" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-INT" class="viewSource">view source</a></div><a name="INT"></a><a name="property-INT"></a><a href="Ext.data.Types.html#" rel="property-INT" class="cls expand">INT</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into an integer before it is placed into a Record.
110
111 The synonym I...</div><div class="long"><p>This data type means that the raw data is converted into an integer before it is placed into a Record.</p>
112
113 <p>The synonym <code>INTEGER</code> is equivalent.</p>
114
115 </div></div></div><div id="property-INTEGER" class="member ni"><a href="Ext.data.Types.html#property-INTEGER" rel="property-INTEGER" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-INTEGER" class="viewSource">view source</a></div><a name="INTEGER"></a><a name="property-INTEGER"></a><a href="Ext.data.Types.html#" rel="property-INTEGER" class="cls expand">INTEGER</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into an integer before it is placed into a Record.
116
117 The synonym I...</div><div class="long"><p>This data type means that the raw data is converted into an integer before it is placed into a Record.</p>
118
119 <p>The synonym <code>INT</code> is equivalent.</p>
120
121 </div></div></div><div id="property-NUMBER" class="member ni"><a href="Ext.data.Types.html#property-NUMBER" rel="property-NUMBER" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-NUMBER" class="viewSource">view source</a></div><a name="NUMBER"></a><a name="property-NUMBER"></a><a href="Ext.data.Types.html#" rel="property-NUMBER" class="cls expand">NUMBER</a><span> : Object.</span></div><div class="description"><div class="short">This data type means that the raw data is converted into a number before it is placed into a Record.
122
123 The synonym FLO...</div><div class="long"><p>This data type means that the raw data is converted into a number before it is placed into a Record.</p>
124
125 <p>The synonym <code>FLOAT</code> is equivalent.</p>
126
127 </div></div></div><div id="property-STRING" class="member ni"><a href="Ext.data.Types.html#property-STRING" rel="property-STRING" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-STRING" class="viewSource">view source</a></div><a name="STRING"></a><a name="property-STRING"></a><a href="Ext.data.Types.html#" rel="property-STRING" class="cls expand">STRING</a><span> : Object.</span></div><div class="description"><div class="short"><p>This data type means that the raw data is converted into a String before it is placed into a Record.</p>
128 </div><div class="long"><p>This data type means that the raw data is converted into a String before it is placed into a Record.</p>
129 </div></div></div><div id="property-stripRe" class="member ni"><a href="Ext.data.Types.html#property-stripRe" rel="property-stripRe" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.Types.html" class="definedIn docClass">Ext.data.Types</a><br/><a href="../source/Types.html#Ext-data.Types-property-stripRe" class="viewSource">view source</a></div><a name="stripRe"></a><a name="property-stripRe"></a><a href="Ext.data.Types.html#" rel="property-stripRe" class="cls expand">stripRe</a><span> : Regexp</span></div><div class="description"><div class="short">A regular expression for stripping non-numeric characters from a numeric value. Defaults to /[\$,%]/g.
130 This should be...</div><div class="long"><p>A regular expression for stripping non-numeric characters from a numeric value. Defaults to <tt>/[\$,%]/g</tt>.
131 This should be overridden for localization.</p>
132 </div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>