Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Date2.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-Date'>/**
19 </span> * @class Ext.grid.column.Date
20  * @extends Ext.grid.column.Column
21  *
22  * A Column definition class which renders a passed date according to the default locale, or a configured
23  * {@link #format}.
24  *
25  * {@img Ext.grid.column.Date/Ext.grid.column.Date.png Ext.grid.column.Date grid column}
26  *
27  * ## Code
28  *
29  *     Ext.create('Ext.data.Store', {
30  *         storeId:'sampleStore',
31  *         fields:[
32  *             {name: 'symbol', type: 'string'},
33  *             {name: 'date', type: 'date'},
34  *             {name: 'change', type: 'number'},
35  *             {name: 'volume', type: 'number'},
36  *             {name: 'topday', type: 'date'}                        
37  *         ],
38  *         data:[
39  *             {symbol:&quot;msft&quot;, date:'2011/04/22', change:2.43, volume:61606325, topday:'04/01/2010'},
40  *             {symbol:&quot;goog&quot;, date:'2011/04/22', change:0.81, volume:3053782, topday:'04/11/2010'},
41  *             {symbol:&quot;apple&quot;, date:'2011/04/22', change:1.35, volume:24484858, topday:'04/28/2010'},            
42  *             {symbol:&quot;sencha&quot;, date:'2011/04/22', change:8.85, volume:5556351, topday:'04/22/2010'}            
43  *         ]
44  *     });
45  *     
46  *     Ext.create('Ext.grid.Panel', {
47  *         title: 'Date Column Demo',
48  *         store: Ext.data.StoreManager.lookup('sampleStore'),
49  *         columns: [
50  *             {text: 'Symbol',  dataIndex: 'symbol', flex: 1},
51  *             {text: 'Date',  dataIndex: 'date', xtype: 'datecolumn', format:'Y-m-d'},
52  *             {text: 'Change',  dataIndex: 'change', xtype: 'numbercolumn', format:'0.00'},
53  *             {text: 'Volume',  dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000'},
54  *             {text: 'Top Day',  dataIndex: 'topday', xtype: 'datecolumn', format:'l'}            
55  *         ],
56  *         height: 200,
57  *         width: 450,
58  *         renderTo: Ext.getBody()
59  *     });
60  *    
61  * @xtype datecolumn
62  */
63 Ext.define('Ext.grid.column.Date', {
64     extend: 'Ext.grid.column.Column',
65     alias: ['widget.datecolumn'],
66     requires: ['Ext.Date'],
67     alternateClassName: 'Ext.grid.DateColumn',
68
69 <span id='Ext-grid-column-Date-cfg-format'>    /**
70 </span>     * @cfg {String} format
71      * A formatting string as used by {@link Date#format Date.format} to format a Date for this Column.
72      * This defaults to the default date from {@link Ext.Date#defaultFormat} which itself my be overridden
73      * in a locale file.
74      */
75     format : Ext.Date.defaultFormat,
76
77     constructor: function(cfg){
78         this.callParent(arguments);
79         this.renderer = Ext.util.Format.dateRenderer(this.format);
80     }
81 });</pre>
82 </body>
83 </html>