Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / SortTypes.html
index 06b93b9..9bf6446 100644 (file)
@@ -1,69 +1,95 @@
-<html>
-<head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
+<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-data.SortTypes'>/**
+</span> * @class Ext.data.SortTypes
+ * This class defines a series of static methods that are used on a
+ * {@link Ext.data.Field} for performing sorting. The methods cast the 
+ * underlying values into a data type that is appropriate for sorting on
+ * that particular field.  If a {@link Ext.data.Field#type} is specified, 
+ * the sortType will be set to a sane default if the sortType is not 
+ * explicitly defined on the field. The sortType will make any necessary
+ * modifications to the value and return it.
+ * &lt;ul&gt;
+ * &lt;li&gt;&lt;b&gt;asText&lt;/b&gt; - Removes any tags and converts the value to a string&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;asUCText&lt;/b&gt; - Removes any tags and converts the value to an uppercase string&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;asUCText&lt;/b&gt; - Converts the value to an uppercase string&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;asDate&lt;/b&gt; - Converts the value into Unix epoch time&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;asFloat&lt;/b&gt; - Converts the value to a floating point number&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;asInt&lt;/b&gt; - Converts the value to an integer number&lt;/li&gt;
+ * &lt;/ul&gt;
+ * &lt;p&gt;
+ * It is also possible to create a custom sortType that can be used throughout
+ * an application.
+ * &lt;pre&gt;&lt;code&gt;
+Ext.apply(Ext.data.SortTypes, {
+    asPerson: function(person){
+        // expects an object with a first and last name property
+        return person.lastName.toUpperCase() + person.firstName.toLowerCase();
+    }    
+});
 
-<div id="cls-Ext.data.SortTypes"></div>/**
- * @class Ext.data.SortTypes
+Ext.define('Employee', {
+    extend: 'Ext.data.Model',
+    fields: [{
+        name: 'person',
+        sortType: 'asPerson'
+    }, {
+        name: 'salary',
+        type: 'float' // sortType set to asFloat
+    }]
+});
+ * &lt;/code&gt;&lt;/pre&gt;
+ * &lt;/p&gt;
  * @singleton
- * Defines the default sorting (casting?) comparison functions used when sorting data.
+ * @docauthor Evan Trimboli &lt;evan@sencha.com&gt;
  */
-Ext.data.SortTypes = {
-    <div id="method-Ext.data.SortTypes-none"></div>/**
-     * Default sort that does nothing
+Ext.define('Ext.data.SortTypes', {
+    
+    singleton: true,
+    
+<span id='Ext-data.SortTypes-method-none'>    /**
+</span>     * Default sort that does nothing
      * @param {Mixed} s The value being converted
      * @return {Mixed} The comparison value
      */
-    none : function(s){
+    none : function(s) {
         return s;
     },
-    
-    <div id="prop-Ext.data.SortTypes-stripTagsRE"></div>/**
-     * The regular expression used to strip tags
+
+<span id='Ext-data.SortTypes-property-stripTagsRE'>    /**
+</span>     * The regular expression used to strip tags
      * @type {RegExp}
      * @property
      */
-    stripTagsRE : /<\/?[^>]+>/gi,
-    
-    <div id="method-Ext.data.SortTypes-asText"></div>/**
-     * Strips all HTML tags to sort on text only
+    stripTagsRE : /&lt;\/?[^&gt;]+&gt;/gi,
+
+<span id='Ext-data.SortTypes-method-asText'>    /**
+</span>     * Strips all HTML tags to sort on text only
      * @param {Mixed} s The value being converted
      * @return {String} The comparison value
      */
-    asText : function(s){
-        return String(s).replace(this.stripTagsRE, "");
+    asText : function(s) {
+        return String(s).replace(this.stripTagsRE, &quot;&quot;);
     },
-    
-    <div id="method-Ext.data.SortTypes-asUCText"></div>/**
-     * Strips all HTML tags to sort on text only - Case insensitive
+
+<span id='Ext-data.SortTypes-method-asUCText'>    /**
+</span>     * Strips all HTML tags to sort on text only - Case insensitive
      * @param {Mixed} s The value being converted
      * @return {String} The comparison value
      */
-    asUCText : function(s){
-        return String(s).toUpperCase().replace(this.stripTagsRE, "");
+    asUCText : function(s) {
+        return String(s).toUpperCase().replace(this.stripTagsRE, &quot;&quot;);
     },
-    
-    <div id="method-Ext.data.SortTypes-asUCString"></div>/**
-     * Case insensitive string
+
+<span id='Ext-data.SortTypes-method-asUCString'>    /**
+</span>     * Case insensitive string
      * @param {Mixed} s The value being converted
      * @return {String} The comparison value
      */
     asUCString : function(s) {
-       return String(s).toUpperCase();
+        return String(s).toUpperCase();
     },
-    
-    <div id="method-Ext.data.SortTypes-asDate"></div>/**
-     * Date sorting
+
+<span id='Ext-data.SortTypes-method-asDate'>    /**
+</span>     * Date sorting
      * @param {Mixed} s The value being converted
      * @return {Number} The comparison value
      */
@@ -74,28 +100,26 @@ Ext.data.SortTypes = {
         if(Ext.isDate(s)){
             return s.getTime();
         }
-       return Date.parse(String(s));
+        return Date.parse(String(s));
     },
-    
-    <div id="method-Ext.data.SortTypes-asFloat"></div>/**
-     * Float sorting
+
+<span id='Ext-data.SortTypes-method-asFloat'>    /**
+</span>     * Float sorting
      * @param {Mixed} s The value being converted
      * @return {Float} The comparison value
      */
     asFloat : function(s) {
-       var val = parseFloat(String(s).replace(/,/g, ""));
-       return isNaN(val) ? 0 : val;
+        var val = parseFloat(String(s).replace(/,/g, &quot;&quot;));
+        return isNaN(val) ? 0 : val;
     },
-    
-    <div id="method-Ext.data.SortTypes-asInt"></div>/**
-     * Integer sorting
+
+<span id='Ext-data.SortTypes-method-asInt'>    /**
+</span>     * Integer sorting
      * @param {Mixed} s The value being converted
      * @return {Number} The comparison value
      */
     asInt : function(s) {
-        var val = parseInt(String(s).replace(/,/g, ""), 10);
+        var val = parseInt(String(s).replace(/,/g, &quot;&quot;), 10);
         return isNaN(val) ? 0 : val;
     }
-};</pre>    
-</body>
-</html>
\ No newline at end of file
+});</pre></pre></body></html>
\ No newline at end of file