Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / grid / property / HeaderContainer.js
index aa7fd4d..a0054ac 100644 (file)
@@ -1,16 +1,29 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+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.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @class Ext.grid.property.HeaderContainer
  * @extends Ext.grid.header.Container
  * A custom HeaderContainer for the {@link Ext.grid.property.Grid}.  Generally it should not need to be used directly.
- * @constructor
- * @param {Ext.grid.property.Grid} grid The grid this store will be bound to
- * @param {Object} source The source data config object
  */
 Ext.define('Ext.grid.property.HeaderContainer', {
 
     extend: 'Ext.grid.header.Container',
 
     alternateClassName: 'Ext.grid.PropertyColumnModel',
+    
+    nameWidth: 115,
 
     // private - strings used for locale support
     nameText : 'Name',
@@ -21,27 +34,31 @@ Ext.define('Ext.grid.property.HeaderContainer', {
 
     // private
     nameColumnCls: Ext.baseCSSPrefix + 'grid-property-name',
-    
-    constructor : function(grid, store) {
 
-        this.grid = grid;
-        this.store = store;
-        this.callParent([{
+    /**
+     * Creates new HeaderContainer.
+     * @param {Ext.grid.property.Grid} grid The grid this store will be bound to
+     * @param {Object} source The source data config object
+     */
+    constructor : function(grid, store) {
+        var me = this;
+        
+        me.grid = grid;
+        me.store = store;
+        me.callParent([{
             items: [{
-                header: this.nameText,
-                width: 115,
+                header: me.nameText,
+                width: grid.nameColumnWidth || me.nameWidth,
                 sortable: true,
                 dataIndex: grid.nameField,
-                renderer: Ext.Function.bind(this.renderProp, this),
+                renderer: Ext.Function.bind(me.renderProp, me),
                 itemId: grid.nameField,
                 menuDisabled :true,
-                tdCls: this.nameColumnCls
+                tdCls: me.nameColumnCls
             }, {
-                header: this.valueText,
-                renderer: Ext.Function.bind(this.renderCell, this),
-                getEditor: function(record) {
-                    return grid.getCellEditor(record, this);
-                },
+                header: me.valueText,
+                renderer: Ext.Function.bind(me.renderCell, me),
+                getEditor: Ext.Function.bind(me.getCellEditor, me),
                 flex: 1,
                 fixed: true,
                 dataIndex: grid.valueField,
@@ -50,6 +67,10 @@ Ext.define('Ext.grid.property.HeaderContainer', {
             }]
         }]);
     },
+    
+    getCellEditor: function(record){
+        return this.grid.getCellEditor(record, this);
+    },
 
     // private
     // Render a property name cell
@@ -61,16 +82,16 @@ Ext.define('Ext.grid.property.HeaderContainer', {
     // Render a property value cell
     renderCell : function(val, meta, rec) {
         var me = this,
-            renderer = this.grid.customRenderers[rec.get(me.grid.nameField)],
+            renderer = me.grid.customRenderers[rec.get(me.grid.nameField)],
             result = val;
 
         if (renderer) {
-            return renderer.apply(this, arguments);
+            return renderer.apply(me, arguments);
         }
         if (Ext.isDate(val)) {
-            result = this.renderDate(val);
+            result = me.renderDate(val);
         } else if (Ext.isBoolean(val)) {
-            result = this.renderBool(val);
+            result = me.renderBool(val);
         }
         return Ext.util.Format.htmlEncode(result);
     },
@@ -89,4 +110,4 @@ Ext.define('Ext.grid.property.HeaderContainer', {
         var pn = this.grid.propertyNames;
         return pn && pn[name] ? pn[name] : name;
     }
-});
\ No newline at end of file
+});