<html>\r
<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
<title>The source code</title>\r
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
* <p>While subclasses are provided to render data in different ways, this class renders a passed\r
* data field unchanged and is usually used for textual columns.</p>\r
*/\r
-Ext.grid.Column = function(config){\r
- Ext.apply(this, config);\r
-\r
- if(typeof this.renderer == 'string'){\r
- this.renderer = Ext.util.Format[this.renderer];\r
- } else if(Ext.isObject(this.renderer)){\r
- this.scope = this.renderer.scope;\r
- this.renderer = this.renderer.fn;\r
- }\r
- this.renderer = this.renderer.createDelegate(this.scope || config);\r
-\r
- if(this.id === undefined){\r
- this.id = ++Ext.grid.Column.AUTO_ID;\r
- }\r
- if(this.editor){\r
- this.editor = Ext.create(this.editor, 'textfield');\r
- }\r
-};\r
-\r
-Ext.grid.Column.AUTO_ID = 0;\r
-\r
-Ext.grid.Column.prototype = {\r
+Ext.grid.Column = Ext.extend(Object, {\r
<div id="cfg-Ext.grid.Column-editable"></div>/**\r
* @cfg {Boolean} editable Optional. Defaults to <tt>true</tt>, enabling the configured\r
* <tt>{@link #editor}</tt>. Set to <tt>false</tt> to initially disable editing on this column.\r
*/\r
<div id="cfg-Ext.grid.Column-sortable"></div>/**\r
* @cfg {Boolean} sortable Optional. <tt>true</tt> if sorting is to be allowed on this column.\r
- * Defaults to the value of the {@link #defaultSortable} property.\r
- * Whether local/remote sorting is used is specified in {@link Ext.data.Store#remoteSort}.\r
+ * Defaults to the value of the <code>{@link Ext.grid.ColumnModel#defaultSortable}</code> property.\r
+ * Whether local/remote sorting is used is specified in <code>{@link Ext.data.Store#remoteSort}</code>.\r
*/\r
<div id="cfg-Ext.grid.Column-fixed"></div>/**\r
* @cfg {Boolean} fixed Optional. <tt>true</tt> if the column width cannot be changed. Defaults to <tt>false</tt>.\r
* @cfg {Boolean} menuDisabled Optional. <tt>true</tt> to disable the column menu. Defaults to <tt>false</tt>.\r
*/\r
<div id="cfg-Ext.grid.Column-hidden"></div>/**\r
- * @cfg {Boolean} hidden Optional. <tt>true</tt> to hide the column. Defaults to <tt>false</tt>.\r
+ * @cfg {Boolean} hidden\r
+ * Optional. <tt>true</tt> to initially hide this column. Defaults to <tt>false</tt>.\r
+ * A hidden column {@link Ext.grid.GridPanel#enableColumnHide may be shown via the header row menu}.\r
+ * If a column is never to be shown, simply do not include this column in the Column Model at all. \r
*/\r
<div id="cfg-Ext.grid.Column-tooltip"></div>/**\r
* @cfg {String} tooltip Optional. A text string to use as the column header's tooltip. If Quicktips\r
* if editing is supported by the grid. See <tt>{@link #editable}</tt> also.\r
*/\r
\r
- // private. Used by ColumnModel to avoid reprocessing\r
+ /**\r
+ * @private\r
+ * @cfg {Boolean} isColumn\r
+ * Used by ColumnModel setConfig method to avoid reprocessing a Column\r
+ * if <code>isColumn</code> is not set ColumnModel will recreate a new Ext.grid.Column\r
+ * Defaults to true.\r
+ */\r
isColumn : true,\r
+ \r
+ constructor : function(config){\r
+ Ext.apply(this, config);\r
+ \r
+ if(Ext.isString(this.renderer)){\r
+ this.renderer = Ext.util.Format[this.renderer];\r
+ }else if(Ext.isObject(this.renderer)){\r
+ this.scope = this.renderer.scope;\r
+ this.renderer = this.renderer.fn;\r
+ }\r
+ if(!this.scope){\r
+ this.scope = this;\r
+ }\r
+ \r
+ var ed = this.editor;\r
+ delete this.editor;\r
+ this.setEditor(ed);\r
+ },\r
+\r
<div id="prop-Ext.grid.Column-renderer"></div>/**\r
* Optional. A function which returns displayable data when passed the following parameters:\r
* <div class="mdetail-params"><ul>\r
* @type Function\r
*/\r
renderer : function(value){\r
- if(typeof value == 'string' && value.length < 1){\r
+ if(Ext.isString(value) && value.length < 1){\r
return ' ';\r
}\r
return value;\r
getEditor: function(rowIndex){\r
return this.editable !== false ? this.editor : null;\r
},\r
+ \r
+ <div id="method-Ext.grid.Column-setEditor"></div>/**\r
+ * Sets a new editor for this column.\r
+ * @param {Ext.Editor/Ext.form.Field} editor The editor to set\r
+ */\r
+ setEditor : function(editor){\r
+ if(this.editor){\r
+ this.editor.destroy();\r
+ }\r
+ this.editor = null;\r
+ if(editor){\r
+ //not an instance, create it\r
+ if(!editor.isXType){\r
+ editor = Ext.create(editor, 'textfield');\r
+ }\r
+ //check if it's wrapped in an editor\r
+ if(!editor.startEdit){\r
+ editor = new Ext.grid.GridEditor(editor);\r
+ }\r
+ this.editor = editor;\r
+ }\r
+ },\r
+ \r
+ destroy : function(){\r
+ this.setEditor(null);\r
+ },\r
\r
<div id="method-Ext.grid.Column-getCellEditor"></div>/**\r
* Returns the {@link Ext.Editor editor} defined for this column that was created to wrap the {@link Ext.form.Field Field}\r
* @return {Ext.Editor}\r
*/\r
getCellEditor: function(rowIndex){\r
- var editor = this.getEditor(rowIndex);\r
- if(editor){\r
- if(!editor.startEdit){\r
- if(!editor.gridEditor){\r
- editor.gridEditor = new Ext.grid.GridEditor(editor);\r
- }\r
- return editor.gridEditor;\r
- }else if(editor.startEdit){\r
- return editor;\r
- }\r
- }\r
- return null;\r
+ return this.getEditor(rowIndex);\r
}\r
-};\r
+});\r
\r
<div id="cls-Ext.grid.BooleanColumn"></div>/**\r
* @class Ext.grid.BooleanColumn\r
* @extends Ext.grid.Column\r
- * <p>A Column definition class which renders boolean data fields. See the {@link Ext.grid.ColumnModel#xtype xtype}\r
- * config option of {@link Ext.grid.ColumnModel} for more details.</p>\r
+ * <p>A Column definition class which renders boolean data fields. See the {@link Ext.grid.Column#xtype xtype}\r
+ * config option of {@link Ext.grid.Column} for more details.</p>\r
*/\r
Ext.grid.BooleanColumn = Ext.extend(Ext.grid.Column, {\r
<div id="cfg-Ext.grid.BooleanColumn-trueText"></div>/**\r
* @class Ext.grid.NumberColumn\r
* @extends Ext.grid.Column\r
* <p>A Column definition class which renders a numeric data field according to a {@link #format} string. See the\r
- * {@link Ext.grid.ColumnModel#xtype xtype} config option of {@link Ext.grid.ColumnModel} for more details.</p>\r
+ * {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column} for more details.</p>\r
*/\r
Ext.grid.NumberColumn = Ext.extend(Ext.grid.Column, {\r
<div id="cfg-Ext.grid.NumberColumn-format"></div>/**\r
* @class Ext.grid.DateColumn\r
* @extends Ext.grid.Column\r
* <p>A Column definition class which renders a passed date according to the default locale, or a configured\r
- * {@link #format}. See the {@link Ext.grid.ColumnModel#xtype xtype} config option of {@link Ext.grid.ColumnModel}\r
+ * {@link #format}. See the {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column}\r
* for more details.</p>\r
*/\r
Ext.grid.DateColumn = Ext.extend(Ext.grid.Column, {\r
* @extends Ext.grid.Column\r
* <p>A Column definition class which renders a value by processing a {@link Ext.data.Record Record}'s\r
* {@link Ext.data.Record#data data} using a {@link #tpl configured} {@link Ext.XTemplate XTemplate}.\r
- * See the {@link Ext.grid.ColumnModel#xtype xtype} config option of {@link Ext.grid.ColumnModel} for more\r
+ * See the {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column} for more\r
* details.</p>\r
*/\r
Ext.grid.TemplateColumn = Ext.extend(Ext.grid.Column, {\r
*/\r
constructor: function(cfg){\r
Ext.grid.TemplateColumn.superclass.constructor.call(this, cfg);\r
- var tpl = typeof Ext.isObject(this.tpl) ? this.tpl : new Ext.XTemplate(this.tpl);\r
+ var tpl = (!Ext.isPrimitive(this.tpl) && this.tpl.compile) ? this.tpl : new Ext.XTemplate(this.tpl);\r
this.renderer = function(value, p, r){\r
return tpl.apply(r.data);\r
};\r