Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / Column.html
index 1f9319f..0bab9bf 100644 (file)
@@ -221,7 +221,7 @@ var grid = new Ext.grid.GridPanel({
     \r
     constructor : function(config){\r
         Ext.apply(this, config);\r
-\r
+        \r
         if(Ext.isString(this.renderer)){\r
             this.renderer = Ext.util.Format[this.renderer];\r
         }else if(Ext.isObject(this.renderer)){\r
@@ -231,10 +231,10 @@ var grid = new Ext.grid.GridPanel({
         if(!this.scope){\r
             this.scope = this;\r
         }\r
-\r
-        if(this.editor){\r
-            this.editor = Ext.create(this.editor, 'textfield');\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
@@ -266,6 +266,32 @@ var grid = new Ext.grid.GridPanel({
     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
@@ -274,18 +300,7 @@ var grid = new Ext.grid.GridPanel({
      * @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