Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / grid / plugin / Editing.js
index 9dc5956..4e1abd1 100644 (file)
@@ -1,15 +1,24 @@
+/*
 
-/**
- * @class Ext.grid.plugin.Editing
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
 
-This class provides an abstract grid editing plugin on selected {@link Ext.grid.column.Column columns}.
-The editable columns are specified by providing an {@link Ext.grid.column.Column#editor editor}
-in the {@link Ext.grid.column.Column column configuration}.
+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.
 
-*Note:* This class should not be used directly. See {@link Ext.grid.plugin.CellEditing} and
-{@link Ext.grid.plugin.RowEditing}.
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
 
- * @markdown
+*/
+/**
+ * This class provides an abstract grid editing plugin on selected {@link Ext.grid.column.Column columns}.
+ * The editable columns are specified by providing an {@link Ext.grid.column.Column#editor editor}
+ * in the {@link Ext.grid.column.Column column configuration}.
+ *
+ * **Note:** This class should not be used directly. See {@link Ext.grid.plugin.CellEditing} and
+ * {@link Ext.grid.plugin.RowEditing}.
  */
 Ext.define('Ext.grid.plugin.Editing', {
     alias: 'editing.editing',
@@ -25,7 +34,7 @@ Ext.define('Ext.grid.plugin.Editing', {
 
     /**
      * @cfg {Number} clicksToEdit
-     * The number of clicks on a grid required to display the editor (defaults to 2).
+     * The number of clicks on a grid required to display the editor.
      */
     clicksToEdit: 2,
 
@@ -61,7 +70,8 @@ Ext.define('Ext.grid.plugin.Editing', {
         me.grid = grid;
         me.view = grid.view;
         me.initEvents();
-        me.initFieldAccessors(me.view.getGridColumns());
+        me.mon(grid, 'reconfigure', me.onReconfigure, me);
+        me.onReconfigure();
 
         grid.relayEvents(me, ['beforeedit', 'edit', 'validateedit']);
         // Marks the grid as editable, so that the SelectionModel
@@ -70,6 +80,14 @@ Ext.define('Ext.grid.plugin.Editing', {
         grid.editingPlugin = grid.view.editingPlugin = me;
     },
 
+    /**
+     * Fires after the grid is reconfigured
+     * @private
+     */
+    onReconfigure: function(){
+        this.initFieldAccessors(this.view.getGridColumns());
+    },
+
     /**
      * @private
      * AbstractComponent calls destroy on all its plugins at destroy time.
@@ -235,16 +253,17 @@ Ext.define('Ext.grid.plugin.Editing', {
 
     /**
      * @private
-     * @abstract. Template method called before editing begins.
+     * @template
+     * Template method called before editing begins.
      * @param {Object} context The current editing context
      * @return {Boolean} Return false to cancel the editing process
      */
     beforeEdit: Ext.emptyFn,
 
     /**
-     * Start editing the specified record, using the specified Column definition to define which field is being edited.
-     * @param {Model} record The Store data record which backs the row to be edited.
-     * @param {Model} columnHeader The Column object defining the column to be edited.
+     * Starts editing the specified record, using the specified Column definition to define which field is being edited.
+     * @param {Ext.data.Model/Number} record The Store data record which backs the row to be edited, or index of the record in Store.
+     * @param {Ext.grid.column.Column/Number} columnHeader The Column object defining the column to be edited, or index of the column.
      */
     startEdit: function(record, columnHeader) {
         var me = this,
@@ -259,7 +278,8 @@ Ext.define('Ext.grid.plugin.Editing', {
     },
 
     /**
-     * @private Collects all information necessary for any subclasses to perform their editing functions.
+     * @private
+     * Collects all information necessary for any subclasses to perform their editing functions.
      * @param record
      * @param columnHeader
      * @returns {Object} The editing context based upon the passed record and column
@@ -301,14 +321,14 @@ Ext.define('Ext.grid.plugin.Editing', {
     },
 
     /**
-     * Cancel any active edit that is in progress.
+     * Cancels any active edit that is in progress.
      */
     cancelEdit: function() {
         this.editing = false;
     },
 
     /**
-     * Complete the edit if there is an active edit in progress.
+     * Completes the edit if there is an active edit in progress.
      */
     completeEdit: function() {
         var me = this;
@@ -328,4 +348,5 @@ Ext.define('Ext.grid.plugin.Editing', {
 
         return me.fireEvent('validateedit', me, context) !== false && !context.cancel;
     }
-});
\ No newline at end of file
+});
+