Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / HeaderContainer.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-property-HeaderContainer-method-constructor'><span id='Ext-grid-property-HeaderContainer'>/**
19 </span></span> * @class Ext.grid.property.HeaderContainer
20  * @extends Ext.grid.header.Container
21  * A custom HeaderContainer for the {@link Ext.grid.property.Grid}.  Generally it should not need to be used directly.
22  * @constructor
23  * @param {Ext.grid.property.Grid} grid The grid this store will be bound to
24  * @param {Object} source The source data config object
25  */
26 Ext.define('Ext.grid.property.HeaderContainer', {
27
28     extend: 'Ext.grid.header.Container',
29
30     alternateClassName: 'Ext.grid.PropertyColumnModel',
31
32     // private - strings used for locale support
33     nameText : 'Name',
34     valueText : 'Value',
35     dateFormat : 'm/j/Y',
36     trueText: 'true',
37     falseText: 'false',
38
39     // private
40     nameColumnCls: Ext.baseCSSPrefix + 'grid-property-name',
41     
42     constructor : function(grid, store) {
43
44         this.grid = grid;
45         this.store = store;
46         this.callParent([{
47             items: [{
48                 header: this.nameText,
49                 width: 115,
50                 sortable: true,
51                 dataIndex: grid.nameField,
52                 renderer: Ext.Function.bind(this.renderProp, this),
53                 itemId: grid.nameField,
54                 menuDisabled :true,
55                 tdCls: this.nameColumnCls
56             }, {
57                 header: this.valueText,
58                 renderer: Ext.Function.bind(this.renderCell, this),
59                 getEditor: function(record) {
60                     return grid.getCellEditor(record, this);
61                 },
62                 flex: 1,
63                 fixed: true,
64                 dataIndex: grid.valueField,
65                 itemId: grid.valueField,
66                 menuDisabled: true
67             }]
68         }]);
69     },
70
71     // private
72     // Render a property name cell
73     renderProp : function(v) {
74         return this.getPropertyName(v);
75     },
76
77     // private
78     // Render a property value cell
79     renderCell : function(val, meta, rec) {
80         var me = this,
81             renderer = this.grid.customRenderers[rec.get(me.grid.nameField)],
82             result = val;
83
84         if (renderer) {
85             return renderer.apply(this, arguments);
86         }
87         if (Ext.isDate(val)) {
88             result = this.renderDate(val);
89         } else if (Ext.isBoolean(val)) {
90             result = this.renderBool(val);
91         }
92         return Ext.util.Format.htmlEncode(result);
93     },
94
95     // private
96     renderDate : Ext.util.Format.date,
97
98     // private
99     renderBool : function(bVal) {
100         return this[bVal ? 'trueText' : 'falseText'];
101     },
102
103     // private
104     // Renders custom property names instead of raw names if defined in the Grid
105     getPropertyName : function(name) {
106         var pn = this.grid.propertyNames;
107         return pn &amp;&amp; pn[name] ? pn[name] : name;
108     }
109 });</pre>
110 </body>
111 </html>