X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/source/Types.html diff --git a/docs/source/Types.html b/docs/source/Types.html index f385ff2b..54fed8f9 100644 --- a/docs/source/Types.html +++ b/docs/source/Types.html @@ -1,41 +1,27 @@ - - - - The source code - - - - -
/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-
/** - * @class Ext.data.Types - *

This is s static class containing the system-supplied data types which may be given to a {@link Ext.data.Field Field}.

- *

The properties in this class are used as type indicators in the {@link Ext.data.Field Field} class, so to +Sencha Documentation Project

/**
+ * @class Ext.data.Types
+ * <p>This is s static class containing the system-supplied data types which may be given to a {@link Ext.data.Field Field}.<p/>
+ * <p>The properties in this class are used as type indicators in the {@link Ext.data.Field Field} class, so to
  * test whether a Field is of a certain type, compare the {@link Ext.data.Field#type type} property against properties
- * of this class.

- *

Developers may add their own application-specific data types to this class. Definition names must be UPPERCASE. - * each type definition must contain three properties:

- *
    - *
  • convert : Function
    A function to convert raw data values from a data block into the data + * of this class.</p> + * <p>Developers may add their own application-specific data types to this class. Definition names must be UPPERCASE. + * each type definition must contain three properties:</p> + * <div class="mdetail-params"><ul> + * <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 * to be stored in the Field. The function is passed the collowing parameters: - *
      - *
    • v : Mixed
      The data value as read by the Reader, if undefined will use - * the configured {@link Ext.data.Field#defaultValue defaultValue}.
    • - *
    • rec : Mixed
      The data object containing the row as read by the Reader. - * Depending on the Reader type, this could be an Array ({@link Ext.data.ArrayReader ArrayReader}), an object - * ({@link Ext.data.JsonReader JsonReader}), or an XML element ({@link Ext.data.XMLReader XMLReader}).
    • - *
  • - *
  • sortType : Function
    A function to convert the stored data into comparable form, as defined by {@link Ext.data.SortTypes}.
  • - *
  • type : String
    A textual data type name.
  • - *
- *

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 - * which contained the properties lat and long, you would define a new data type like this:

- *

+ * <div class="mdetail-params"><ul>
+ * <li><b>v</b> : Mixed<div class="sub-desc">The data value as read by the Reader, if undefined will use
+ * the configured <tt>{@link Ext.data.Field#defaultValue defaultValue}</tt>.</div></li>
+ * <li><b>rec</b> : Mixed<div class="sub-desc">The data object containing the row as read by the Reader.
+ * Depending on the Reader type, this could be an Array ({@link Ext.data.reader.Array ArrayReader}), an object
+ * ({@link Ext.data.reader.Json JsonReader}), or an XML element.</div></li>
+ * </ul></div></div></li>
+ * <li><code>sortType</code> : <i>Function</i> <div class="sub-desc">A function to convert the stored data into comparable form, as defined by {@link Ext.data.SortTypes}.</div></li>
+ * <li><code>type</code> : <i>String</i> <div class="sub-desc">A textual data type name.</div></li>
+ * </ul></div>
+ * <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
+ * which contained the properties <code>lat</code> and <code>long</code>, you would define a new data type like this:</p>
+ *<pre><code>
 // Add a new Field data type which stores a VELatLong object in the Record.
 Ext.data.Types.VELATLONG = {
     convert: function(v, data) {
@@ -46,120 +32,138 @@ Ext.data.Types.VELATLONG = {
     },
     type: 'VELatLong'
 };
-
- *

Then, when declaring a Record, use


+</code></pre>
+ * <p>Then, when declaring a Model, use <pre><code>
 var types = Ext.data.Types; // allow shorthand type access
-UnitRecord = Ext.data.Record.create([
-    { name: 'unitName', mapping: 'UnitName' },
-    { name: 'curSpeed', mapping: 'CurSpeed', type: types.INT },
-    { name: 'latitude', mapping: 'lat', type: types.FLOAT },
-    { name: 'latitude', mapping: 'lat', type: types.FLOAT },
-    { name: 'position', type: types.VELATLONG }
-]);
-
+Ext.define('Unit', + extend: 'Ext.data.Model', + fields: [ + { name: 'unitName', mapping: 'UnitName' }, + { name: 'curSpeed', mapping: 'CurSpeed', type: types.INT }, + { name: 'latitude', mapping: 'lat', type: types.FLOAT }, + { name: 'latitude', mapping: 'lat', type: types.FLOAT }, + { name: 'position', type: types.VELATLONG } + ] +}); +</code></pre> * @singleton */ -Ext.data.Types = new function(){ +Ext.define('Ext.data.Types', { + singleton: true, + requires: ['Ext.data.SortTypes'] +}, function() { var st = Ext.data.SortTypes; - Ext.apply(this, { -
/** - * @type Regexp + + Ext.apply(Ext.data.Types, { + /** + * @type Regexp * @property stripRe - * A regular expression for stripping non-numeric characters from a numeric value. Defaults to /[\$,%]/g. + * A regular expression for stripping non-numeric characters from a numeric value. Defaults to <tt>/[\$,%]/g</tt>. * This should be overridden for localization. */ stripRe: /[\$,%]/g, -
/** - * @type Object. + /** + * @type Object. * @property AUTO * This data type means that no conversion is applied to the raw data before it is placed into a Record. */ AUTO: { - convert: function(v){ return v; }, + convert: function(v) { + return v; + }, sortType: st.none, type: 'auto' }, -
/** - * @type Object. + /** + * @type Object. * @property STRING * This data type means that the raw data is converted into a String before it is placed into a Record. */ STRING: { - convert: function(v){ return (v === undefined || v === null) ? '' : String(v); }, + convert: function(v) { + var defaultValue = this.useNull ? null : ''; + return (v === undefined || v === null) ? defaultValue : String(v); + }, sortType: st.asUCString, type: 'string' }, -
/** - * @type Object. + /** + * @type Object. * @property INT * This data type means that the raw data is converted into an integer before it is placed into a Record. - *

The synonym INTEGER is equivalent.

+ * <p>The synonym <code>INTEGER</code> is equivalent.</p> */ INT: { - convert: function(v){ - return v !== undefined && v !== null && v !== '' ? + convert: function(v) { + return v !== undefined && v !== null && v !== '' ? parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0); }, sortType: st.none, type: 'int' }, -
/** - * @type Object. + /** + * @type Object. * @property FLOAT * This data type means that the raw data is converted into a number before it is placed into a Record. - *

The synonym NUMBER is equivalent.

+ * <p>The synonym <code>NUMBER</code> is equivalent.</p> */ FLOAT: { - convert: function(v){ - return v !== undefined && v !== null && v !== '' ? + convert: function(v) { + return v !== undefined && v !== null && v !== '' ? parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0); }, sortType: st.none, type: 'float' }, -
/** - * @type Object. + /** + * @type Object. * @property BOOL - *

This data type means that the raw data is converted into a boolean before it is placed into - * a Record. The string "true" and the number 1 are converted to boolean true.

- *

The synonym BOOLEAN is equivalent.

+ * <p>This data type means that the raw data is converted into a boolean before it is placed into + * a Record. The string "true" and the number 1 are converted to boolean <code>true</code>.</p> + * <p>The synonym <code>BOOLEAN</code> is equivalent.</p> */ BOOL: { - convert: function(v){ return v === true || v === 'true' || v == 1; }, + convert: function(v) { + if (this.useNull && v === undefined || v === null || v === '') { + return null; + } + return v === true || v === 'true' || v == 1; + }, sortType: st.none, type: 'bool' }, -
/** - * @type Object. + /** + * @type Object. * @property DATE * This data type means that the raw data is converted into a Date before it is placed into a Record. * The date format is specified in the constructor of the {@link Ext.data.Field} to which this type is * being applied. */ DATE: { - convert: function(v){ + convert: function(v) { var df = this.dateFormat; - if(!v){ + if (!v) { return null; } - if(Ext.isDate(v)){ + if (Ext.isDate(v)) { return v; } - if(df){ - if(df == 'timestamp'){ + if (df) { + if (df == 'timestamp') { return new Date(v*1000); } - if(df == 'time'){ + if (df == 'time') { return new Date(parseInt(v, 10)); } - return Date.parseDate(v, df); + return Ext.Date.parse(v, df); } + var parsed = Date.parse(v); return parsed ? new Date(parsed) : null; }, @@ -168,30 +172,31 @@ Ext.data.Types = new function(){ } }); - Ext.apply(this, { -
/** - * @type Object. + Ext.apply(Ext.data.Types, { + /** + * @type Object. * @property BOOLEAN - *

This data type means that the raw data is converted into a boolean before it is placed into - * a Record. The string "true" and the number 1 are converted to boolean true.

- *

The synonym BOOL is equivalent.

+ * <p>This data type means that the raw data is converted into a boolean before it is placed into + * a Record. The string "true" and the number 1 are converted to boolean <code>true</code>.</p> + * <p>The synonym <code>BOOL</code> is equivalent.</p> */ BOOLEAN: this.BOOL, -
/** - * @type Object. + + /** + * @type Object. * @property INTEGER * This data type means that the raw data is converted into an integer before it is placed into a Record. - *

The synonym INT is equivalent.

+ * <p>The synonym <code>INT</code> is equivalent.</p> */ INTEGER: this.INT, -
/** - * @type Object. + + /** + * @type Object. * @property NUMBER * This data type means that the raw data is converted into a number before it is placed into a Record. - *

The synonym FLOAT is equivalent.

+ * <p>The synonym <code>FLOAT</code> is equivalent.</p> */ NUMBER: this.FLOAT }); -};
- - \ No newline at end of file +}); +
\ No newline at end of file