X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/source/SortTypes.html diff --git a/docs/source/SortTypes.html b/docs/source/SortTypes.html index 06b93b9f..9bf64460 100644 --- a/docs/source/SortTypes.html +++ b/docs/source/SortTypes.html @@ -1,69 +1,95 @@ - - - - The source code - - - - -
/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
+Sencha Documentation Project
/**
+ * @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.
+ * <ul>
+ * <li><b>asText</b> - Removes any tags and converts the value to a string</li>
+ * <li><b>asUCText</b> - Removes any tags and converts the value to an uppercase string</li>
+ * <li><b>asUCText</b> - Converts the value to an uppercase string</li>
+ * <li><b>asDate</b> - Converts the value into Unix epoch time</li>
+ * <li><b>asFloat</b> - Converts the value to a floating point number</li>
+ * <li><b>asInt</b> - Converts the value to an integer number</li>
+ * </ul>
+ * <p>
+ * It is also possible to create a custom sortType that can be used throughout
+ * an application.
+ * <pre><code>
+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();
+    }    
+});
 
-
/** - * @class Ext.data.SortTypes +Ext.define('Employee', { + extend: 'Ext.data.Model', + fields: [{ + name: 'person', + sortType: 'asPerson' + }, { + name: 'salary', + type: 'float' // sortType set to asFloat + }] +}); + * </code></pre> + * </p> * @singleton - * Defines the default sorting (casting?) comparison functions used when sorting data. + * @docauthor Evan Trimboli <evan@sencha.com> */ -Ext.data.SortTypes = { -
/** - * Default sort that does nothing +Ext.define('Ext.data.SortTypes', { + + singleton: true, + + /** + * 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; }, - -
/** - * The regular expression used to strip tags + + /** + * The regular expression used to strip tags * @type {RegExp} * @property */ - stripTagsRE : /<\/?[^>]+>/gi, - -
/** - * Strips all HTML tags to sort on text only + stripTagsRE : /<\/?[^>]+>/gi, + + /** + * 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, ""); }, - -
/** - * Strips all HTML tags to sort on text only - Case insensitive + + /** + * 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, ""); }, - -
/** - * Case insensitive string + + /** + * 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(); }, - -
/** - * Date sorting + + /** + * 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)); }, - -
/** - * Float sorting + + /** + * 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, "")); + return isNaN(val) ? 0 : val; }, - -
/** - * Integer sorting + + /** + * 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, ""), 10); return isNaN(val) ? 0 : val; } -};
- - \ No newline at end of file +});
\ No newline at end of file