3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.grid.property.HeaderContainer
17 * @extends Ext.grid.header.Container
18 * A custom HeaderContainer for the {@link Ext.grid.property.Grid}. Generally it should not need to be used directly.
20 Ext.define('Ext.grid.property.HeaderContainer', {
22 extend: 'Ext.grid.header.Container',
24 alternateClassName: 'Ext.grid.PropertyColumnModel',
28 // private - strings used for locale support
36 nameColumnCls: Ext.baseCSSPrefix + 'grid-property-name',
39 * Creates new HeaderContainer.
40 * @param {Ext.grid.property.Grid} grid The grid this store will be bound to
41 * @param {Object} source The source data config object
43 constructor : function(grid, store) {
51 width: grid.nameColumnWidth || me.nameWidth,
53 dataIndex: grid.nameField,
54 renderer: Ext.Function.bind(me.renderProp, me),
55 itemId: grid.nameField,
57 tdCls: me.nameColumnCls
60 renderer: Ext.Function.bind(me.renderCell, me),
61 getEditor: Ext.Function.bind(me.getCellEditor, me),
64 dataIndex: grid.valueField,
65 itemId: grid.valueField,
71 getCellEditor: function(record){
72 return this.grid.getCellEditor(record, this);
76 // Render a property name cell
77 renderProp : function(v) {
78 return this.getPropertyName(v);
82 // Render a property value cell
83 renderCell : function(val, meta, rec) {
85 renderer = me.grid.customRenderers[rec.get(me.grid.nameField)],
89 return renderer.apply(me, arguments);
91 if (Ext.isDate(val)) {
92 result = me.renderDate(val);
93 } else if (Ext.isBoolean(val)) {
94 result = me.renderBool(val);
96 return Ext.util.Format.htmlEncode(result);
100 renderDate : Ext.util.Format.date,
103 renderBool : function(bVal) {
104 return this[bVal ? 'trueText' : 'falseText'];
108 // Renders custom property names instead of raw names if defined in the Grid
109 getPropertyName : function(name) {
110 var pn = this.grid.propertyNames;
111 return pn && pn[name] ? pn[name] : name;