X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/src/widgets/grid/Column.js diff --git a/src/widgets/grid/Column.js b/src/widgets/grid/Column.js index af23de25..d879792c 100644 --- a/src/widgets/grid/Column.js +++ b/src/widgets/grid/Column.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -219,7 +219,7 @@ var grid = new Ext.grid.GridPanel({ constructor : function(config){ Ext.apply(this, config); - + if(Ext.isString(this.renderer)){ this.renderer = Ext.util.Format[this.renderer]; }else if(Ext.isObject(this.renderer)){ @@ -229,10 +229,10 @@ var grid = new Ext.grid.GridPanel({ if(!this.scope){ this.scope = this; } - - if(this.editor){ - this.editor = Ext.create(this.editor, 'textfield'); - } + + var ed = this.editor; + delete this.editor; + this.setEditor(ed); }, /** @@ -264,6 +264,32 @@ var grid = new Ext.grid.GridPanel({ getEditor: function(rowIndex){ return this.editable !== false ? this.editor : null; }, + + /** + * Sets a new editor for this column. + * @param {Ext.Editor/Ext.form.Field} editor The editor to set + */ + setEditor : function(editor){ + if(this.editor){ + this.editor.destroy(); + } + this.editor = null; + if(editor){ + //not an instance, create it + if(!editor.isXType){ + editor = Ext.create(editor, 'textfield'); + } + //check if it's wrapped in an editor + if(!editor.startEdit){ + editor = new Ext.grid.GridEditor(editor); + } + this.editor = editor; + } + }, + + destroy : function(){ + this.setEditor(null); + }, /** * Returns the {@link Ext.Editor editor} defined for this column that was created to wrap the {@link Ext.form.Field Field} @@ -272,18 +298,7 @@ var grid = new Ext.grid.GridPanel({ * @return {Ext.Editor} */ getCellEditor: function(rowIndex){ - var editor = this.getEditor(rowIndex); - if(editor){ - if(!editor.startEdit){ - if(!editor.gridEditor){ - editor.gridEditor = new Ext.grid.GridEditor(editor); - } - return editor.gridEditor; - }else if(editor.startEdit){ - return editor; - } - } - return null; + return this.getEditor(rowIndex); } });