Upgrade to ExtJS 3.2.2 - Released 06/02/2010
[extjs.git] / docs / source / SortTypes.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.2.2
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15
16 <div id="cls-Ext.data.SortTypes"></div>/**
17  * @class Ext.data.SortTypes
18  * @singleton
19  * Defines the default sorting (casting?) comparison functions used when sorting data.
20  */
21 Ext.data.SortTypes = {
22     <div id="method-Ext.data.SortTypes-none"></div>/**
23      * Default sort that does nothing
24      * @param {Mixed} s The value being converted
25      * @return {Mixed} The comparison value
26      */
27     none : function(s){
28         return s;
29     },
30     
31     <div id="prop-Ext.data.SortTypes-stripTagsRE"></div>/**
32      * The regular expression used to strip tags
33      * @type {RegExp}
34      * @property
35      */
36     stripTagsRE : /<\/?[^>]+>/gi,
37     
38     <div id="method-Ext.data.SortTypes-asText"></div>/**
39      * Strips all HTML tags to sort on text only
40      * @param {Mixed} s The value being converted
41      * @return {String} The comparison value
42      */
43     asText : function(s){
44         return String(s).replace(this.stripTagsRE, "");
45     },
46     
47     <div id="method-Ext.data.SortTypes-asUCText"></div>/**
48      * Strips all HTML tags to sort on text only - Case insensitive
49      * @param {Mixed} s The value being converted
50      * @return {String} The comparison value
51      */
52     asUCText : function(s){
53         return String(s).toUpperCase().replace(this.stripTagsRE, "");
54     },
55     
56     <div id="method-Ext.data.SortTypes-asUCString"></div>/**
57      * Case insensitive string
58      * @param {Mixed} s The value being converted
59      * @return {String} The comparison value
60      */
61     asUCString : function(s) {
62         return String(s).toUpperCase();
63     },
64     
65     <div id="method-Ext.data.SortTypes-asDate"></div>/**
66      * Date sorting
67      * @param {Mixed} s The value being converted
68      * @return {Number} The comparison value
69      */
70     asDate : function(s) {
71         if(!s){
72             return 0;
73         }
74         if(Ext.isDate(s)){
75             return s.getTime();
76         }
77         return Date.parse(String(s));
78     },
79     
80     <div id="method-Ext.data.SortTypes-asFloat"></div>/**
81      * Float sorting
82      * @param {Mixed} s The value being converted
83      * @return {Float} The comparison value
84      */
85     asFloat : function(s) {
86         var val = parseFloat(String(s).replace(/,/g, ""));
87         return isNaN(val) ? 0 : val;
88     },
89     
90     <div id="method-Ext.data.SortTypes-asInt"></div>/**
91      * Integer sorting
92      * @param {Mixed} s The value being converted
93      * @return {Number} The comparison value
94      */
95     asInt : function(s) {
96         var val = parseInt(String(s).replace(/,/g, ""), 10);
97         return isNaN(val) ? 0 : val;
98     }
99 };</pre>    
100 </body>
101 </html>