Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / grid / plugin / CellEditing.js
index 1177d8f..4f05dae 100644 (file)
@@ -1,3 +1,17 @@
+/*
+
+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.plugin.CellEditing
  * @extends Ext.grid.plugin.Editing
 /**
  * @class Ext.grid.plugin.CellEditing
  * @extends Ext.grid.plugin.Editing
@@ -62,7 +76,7 @@
 Ext.define('Ext.grid.plugin.CellEditing', {
     alias: 'plugin.cellediting',
     extend: 'Ext.grid.plugin.Editing',
 Ext.define('Ext.grid.plugin.CellEditing', {
     alias: 'plugin.cellediting',
     extend: 'Ext.grid.plugin.Editing',
-    requires: ['Ext.grid.CellEditor'],
+    requires: ['Ext.grid.CellEditor', 'Ext.util.DelayedTask'],
 
     constructor: function() {
         /**
 
     constructor: function() {
         /**
@@ -145,6 +159,12 @@ grid.on('validateedit', function(e) {
         this.editors = Ext.create('Ext.util.MixedCollection', false, function(editor) {
             return editor.editorId;
         });
         this.editors = Ext.create('Ext.util.MixedCollection', false, function(editor) {
             return editor.editorId;
         });
+        this.editTask = Ext.create('Ext.util.DelayedTask');
+    },
+    
+    onReconfigure: function(){
+        this.editors.clear();
+        this.callParent();    
     },
 
     /**
     },
 
     /**
@@ -153,6 +173,7 @@ grid.on('validateedit', function(e) {
      */
     destroy: function() {
         var me = this;
      */
     destroy: function() {
         var me = this;
+        me.editTask.cancel();
         me.editors.each(Ext.destroy, Ext);
         me.editors.clear();
         me.callParent(arguments);
         me.editors.each(Ext.destroy, Ext);
         me.editors.clear();
         me.callParent(arguments);
@@ -221,13 +242,13 @@ grid.on('validateedit', function(e) {
             me.setActiveColumn(columnHeader);
 
             // Defer, so we have some time between view scroll to sync up the editor
             me.setActiveColumn(columnHeader);
 
             // Defer, so we have some time between view scroll to sync up the editor
-            Ext.defer(ed.startEdit, 15, ed, [me.getCell(record, columnHeader), value]);
+            me.editTask.delay(15, ed.startEdit, ed, [me.getCell(record, columnHeader), value]);
         } else {
             // BrowserBug: WebKit & IE refuse to focus the element, rather
             // it will focus it and then immediately focus the body. This
             // temporary hack works for Webkit and IE6. IE7 and 8 are still
             // broken
         } else {
             // BrowserBug: WebKit & IE refuse to focus the element, rather
             // it will focus it and then immediately focus the body. This
             // temporary hack works for Webkit and IE6. IE7 and 8 are still
             // broken
-            me.grid.getView().el.focus((Ext.isWebKit || Ext.isIE) ? 10 : false);
+            me.grid.getView().getEl(columnHeader).focus((Ext.isWebKit || Ext.isIE) ? 10 : false);
         }
     },
 
         }
     },
 
@@ -266,7 +287,7 @@ grid.on('validateedit', function(e) {
     getEditor: function(record, column) {
         var me = this,
             editors = me.editors,
     getEditor: function(record, column) {
         var me = this,
             editors = me.editors,
-            editorId = column.itemId || column.id,
+            editorId = column.getItemId(),
             editor = editors.getByKey(editorId);
 
         if (editor) {
             editor = editors.getByKey(editorId);
 
         if (editor) {
@@ -343,7 +364,7 @@ grid.on('validateedit', function(e) {
                 me.context.record.set(dataIndex, value);
             // Restore focus back to the view's element.
             } else {
                 me.context.record.set(dataIndex, value);
             // Restore focus back to the view's element.
             } else {
-                grid.getView().el.focus();
+                grid.getView().getEl(activeColumn).focus();
             }
             me.context.value = value;
             me.fireEvent('edit', me, me.context);
             }
             me.context.value = value;
             me.fireEvent('edit', me, me.context);
@@ -358,7 +379,7 @@ grid.on('validateedit', function(e) {
     cancelEdit: function() {
         var me = this,
             activeEd = me.getActiveEditor(),
     cancelEdit: function() {
         var me = this,
             activeEd = me.getActiveEditor(),
-            viewEl = me.grid.getView().el;
+            viewEl = me.grid.getView().getEl(me.getActiveColumn());
 
         me.setActiveEditor(null);
         me.setActiveColumn(null);
 
         me.setActiveEditor(null);
         me.setActiveColumn(null);
@@ -385,4 +406,4 @@ grid.on('validateedit', function(e) {
         }
         me.startEdit(editRecord, editColumnHeader);
     }
         }
         me.startEdit(editRecord, editColumnHeader);
     }
-});
\ No newline at end of file
+});