Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / source / Number2.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-grid-column-Number'>/**
19 </span> * @class Ext.grid.column.Number
20  * @extends Ext.grid.column.Column
21  *
22  * A Column definition class which renders a numeric data field according to a {@link #format} string.
23  *
24  * {@img Ext.grid.column.Number/Ext.grid.column.Number.png Ext.grid.column.Number cell editing}
25  *
26  * ## Code
27  *     Ext.create('Ext.data.Store', {
28  *        storeId:'sampleStore',
29  *        fields:[
30  *            {name: 'symbol', type: 'string'},
31  *            {name: 'price', type: 'number'},
32  *            {name: 'change', type: 'number'},
33  *            {name: 'volume', type: 'number'},            
34  *        ],
35  *        data:[
36  *            {symbol:&quot;msft&quot;, price:25.76, change:2.43, volume:61606325},
37  *            {symbol:&quot;goog&quot;, price:525.73, change:0.81, volume:3053782},
38  *            {symbol:&quot;apple&quot;, price:342.41, change:1.35, volume:24484858},            
39  *            {symbol:&quot;sencha&quot;, price:142.08, change:8.85, volume:5556351}            
40  *        ]
41  *     });
42  *     
43  *     Ext.create('Ext.grid.Panel', {
44  *         title: 'Number Column Demo',
45  *         store: Ext.data.StoreManager.lookup('sampleStore'),
46  *         columns: [
47  *             {text: 'Symbol',  dataIndex: 'symbol', flex: 1},
48  *             {text: 'Current Price',  dataIndex: 'price', renderer: Ext.util.Format.usMoney},
49  *             {text: 'Change',  dataIndex: 'change', xtype: 'numbercolumn', format:'0.00'},
50  *             {text: 'Volume',  dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000'}
51  *         ],
52  *         height: 200,
53  *         width: 400,
54  *         renderTo: Ext.getBody()
55  *     });
56  */
57 Ext.define('Ext.grid.column.Number', {
58     extend: 'Ext.grid.column.Column',
59     alias: ['widget.numbercolumn'],
60     requires: ['Ext.util.Format'],
61     alternateClassName: 'Ext.grid.NumberColumn',
62
63 <span id='Ext-grid-column-Number-cfg-format'>    /**
64 </span>     * @cfg {String} format
65      * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column
66      * (defaults to &lt;code&gt;'0,000.00'&lt;/code&gt;).
67      */
68     format : '0,000.00',
69     constructor: function(cfg) {
70         this.callParent(arguments);
71         this.renderer = Ext.util.Format.numberRenderer(this.format);
72     }
73 });</pre>
74 </body>
75 </html>