X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/source/Number3.html diff --git a/docs/source/Number3.html b/docs/source/Number3.html index cd9a4fac..caf77203 100644 --- a/docs/source/Number3.html +++ b/docs/source/Number3.html @@ -1,80 +1,70 @@ -Sencha Documentation Project
/**
- * @class Ext.Number
+
+
+
+  
+  The source code
+  
+  
+  
+  
+
+
+  
/**
+ * A Column definition class which renders a numeric data field according to a {@link #format} string.
  *
- * A collection of useful static methods to deal with numbers
- * @singleton
+ *     @example
+ *     Ext.create('Ext.data.Store', {
+ *        storeId:'sampleStore',
+ *        fields:[
+ *            { name: 'symbol', type: 'string' },
+ *            { name: 'price',  type: 'number' },
+ *            { name: 'change', type: 'number' },
+ *            { name: 'volume', type: 'number' },            
+ *        ],
+ *        data:[
+ *            { symbol: "msft",   price: 25.76,  change: 2.43, volume: 61606325 },
+ *            { symbol: "goog",   price: 525.73, change: 0.81, volume: 3053782  },
+ *            { symbol: "apple",  price: 342.41, change: 1.35, volume: 24484858 },            
+ *            { symbol: "sencha", price: 142.08, change: 8.85, volume: 5556351  }            
+ *        ]
+ *     });
+ *     
+ *     Ext.create('Ext.grid.Panel', {
+ *         title: 'Number Column Demo',
+ *         store: Ext.data.StoreManager.lookup('sampleStore'),
+ *         columns: [
+ *             { text: 'Symbol',         dataIndex: 'symbol', flex: 1 },
+ *             { text: 'Current Price',  dataIndex: 'price',  renderer: Ext.util.Format.usMoney },
+ *             { text: 'Change',         dataIndex: 'change', xtype: 'numbercolumn', format:'0.00' },
+ *             { text: 'Volume',         dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000' }
+ *         ],
+ *         height: 200,
+ *         width: 400,
+ *         renderTo: Ext.getBody()
+ *     });
  */
+Ext.define('Ext.grid.column.Number', {
+    extend: 'Ext.grid.column.Column',
+    alias: ['widget.numbercolumn'],
+    requires: ['Ext.util.Format'],
+    alternateClassName: 'Ext.grid.NumberColumn',
 
-(function() {
-
-var isToFixedBroken = (0.9).toFixed() !== '1';
-
-Ext.Number = {
-    /**
-     * Checks whether or not the current number is within a desired range.  If the number is already within the
-     * range it is returned, otherwise the min or max value is returned depending on which side of the range is
-     * exceeded. Note that this method returns the constrained value but does not change the current number.
-     * @param {Number} number The number to check
-     * @param {Number} min The minimum number in the range
-     * @param {Number} max The maximum number in the range
-     * @return {Number} The constrained value if outside the range, otherwise the current value
-     */
-    constrain: function(number, min, max) {
-        number = parseFloat(number);
-
-        if (!isNaN(min)) {
-            number = Math.max(number, min);
-        }
-        if (!isNaN(max)) {
-            number = Math.min(number, max);
-        }
-        return number;
-    },
-
-    /**
-     * Formats a number using fixed-point notation
-     * @param {Number} value The number to format
-     * @param {Number} precision The number of digits to show after the decimal point
+    /**
+     * @cfg {String} format
+     * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column.
      */
-    toFixed: function(value, precision) {
-        if (isToFixedBroken) {
-            precision = precision || 0;
-            var pow = Math.pow(10, precision);
-            return (Math.round(value * pow) / pow).toFixed(precision);
-        }
-
-        return value.toFixed(precision);
-    },
-
-    /**
-     * Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
-     * it is not.
+    format : '0,000.00',
 
-Ext.Number.from('1.23', 1); // returns 1.23
-Ext.Number.from('abc', 1); // returns 1
-
-     * @param {Mixed} value
-     * @param {Number} defaultValue The value to return if the original value is non-numeric
-     * @return {Number} value, if numeric, defaultValue otherwise
-     */
-    from: function(value, defaultValue) {
-        if (isFinite(value)) {
-            value = parseFloat(value);
-        }
-
-        return !isNaN(value) ? value : defaultValue;
+    constructor: function(cfg) {
+        this.callParent(arguments);
+        this.renderer = Ext.util.Format.numberRenderer(this.format);
     }
-};
-
-})();
-
-/**
- * This method is deprecated, please use {@link Ext.Number#from Ext.Number.from} instead
- *
- * @deprecated 4.0.0 Replaced by Ext.Number.from
- * @member Ext
- * @method num
- */
-Ext.num = function() {
-    return Ext.Number.from.apply(this, arguments);
-};
\ No newline at end of file +});
+ +