X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/source/CellEditing.html diff --git a/docs/source/CellEditing.html b/docs/source/CellEditing.html index ec7a495a..6d449e80 100644 --- a/docs/source/CellEditing.html +++ b/docs/source/CellEditing.html @@ -1,4 +1,21 @@ -
/**
+
+
+
+
+ The source code
+
+
+
+
+
+
+ /**
* @class Ext.grid.plugin.CellEditing
* @extends Ext.grid.plugin.Editing
*
@@ -62,10 +79,10 @@
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() {
- /**
+ /**
* @event beforeedit
* Fires before cell editing is triggered. The edit event object has the following properties <br />
* <ul style="padding:5px;padding-left:16px;">
@@ -82,7 +99,7 @@ Ext.define('Ext.grid.plugin.CellEditing', {
* @param {Ext.grid.plugin.Editing} editor
* @param {Object} e An edit event (see above for description)
*/
- /**
+ /**
* @event edit
* Fires after a cell is edited. The edit event object has the following properties <br />
* <ul style="padding:5px;padding-left:16px;">
@@ -108,7 +125,7 @@ function onEdit(e) {
* @param {Ext.grid.plugin.Editing} editor
* @param {Object} e An edit event (see above for description)
*/
- /**
+ /**
* @event validateedit
* Fires after a cell is edited, but before the value is set in the record. Return false
* to cancel the change. The edit event object has the following properties <br />
@@ -145,33 +162,46 @@ grid.on('validateedit', function(e) {
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();
},
- /**
+ /**
* @private
* AbstractComponent calls destroy on all its plugins at destroy time.
*/
destroy: function() {
var me = this;
+ me.editTask.cancel();
me.editors.each(Ext.destroy, Ext);
me.editors.clear();
me.callParent(arguments);
},
+
+ onBodyScroll: function() {
+ var ed = this.getActiveEditor();
+ if (ed && ed.field) {
+ if (ed.field.triggerBlur) {
+ ed.field.triggerBlur();
+ } else {
+ ed.field.blur();
+ }
+ }
+ },
// private
// Template method called from base class's initEvents
initCancelTriggers: function() {
- var me = this;
+ var me = this,
grid = me.grid,
- view = grid.view;
-
- me.mon(view, {
- mousewheel: {
- element: 'el',
- fn: me.cancelEdit,
- scope: me
- }
- });
+ view = grid.view;
+
+ view.addElListener('mousewheel', me.cancelEdit, me);
+ me.mon(view, 'bodyscroll', me.onBodyScroll, me);
me.mon(grid, {
columnresize: me.cancelEdit,
columnmove: me.cancelEdit,
@@ -179,7 +209,7 @@ grid.on('validateedit', function(e) {
});
},
- /**
+ /**
* 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.
@@ -215,13 +245,13 @@ grid.on('validateedit', function(e) {
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
- me.grid.getView().el.focus((Ext.isWebKit || Ext.isIE) ? 10 : false);
+ me.grid.getView().getEl(columnHeader).focus((Ext.isWebKit || Ext.isIE) ? 10 : false);
}
},
@@ -258,8 +288,9 @@ grid.on('validateedit', function(e) {
},
getEditor: function(record, column) {
- var editors = this.editors,
- editorId = column.itemId || column.id,
+ var me = this,
+ editors = me.editors,
+ editorId = column.getItemId(),
editor = editors.getByKey(editorId);
if (editor) {
@@ -277,20 +308,20 @@ grid.on('validateedit', function(e) {
field: editor
});
}
- editor.parentEl = this.grid.getEditorParent();
+ editor.parentEl = me.grid.getEditorParent();
// editor.parentEl should be set here.
editor.on({
- scope: this,
- specialkey: this.onSpecialKey,
- complete: this.onEditComplete,
- canceledit: this.cancelEdit
+ scope: me,
+ specialkey: me.onSpecialKey,
+ complete: me.onEditComplete,
+ canceledit: me.cancelEdit
});
editors.add(editor);
return editor;
}
},
- /**
+ /**
* Get the cell (td) for a particular record and column.
* @param {Ext.data.Model} record
* @param {Ext.grid.column.Colunm} column
@@ -316,27 +347,42 @@ grid.on('validateedit', function(e) {
var me = this,
grid = me.grid,
sm = grid.getSelectionModel(),
- dataIndex = me.getActiveColumn().dataIndex;
-
- me.setActiveEditor(null);
- me.setActiveColumn(null);
- me.setActiveRecord(null);
- delete sm.wasEditing;
+ activeColumn = me.getActiveColumn(),
+ dataIndex;
+
+ if (activeColumn) {
+ dataIndex = activeColumn.dataIndex;
+
+ me.setActiveEditor(null);
+ me.setActiveColumn(null);
+ me.setActiveRecord(null);
+ delete sm.wasEditing;
+
+ if (!me.validateEdit()) {
+ return;
+ }
+ // Only update the record if the new value is different than the
+ // startValue, when the view refreshes its el will gain focus
+ if (value !== startValue) {
+ me.context.record.set(dataIndex, value);
+ // Restore focus back to the view's element.
+ } else {
+ grid.getView().getEl(activeColumn).focus();
+ }
+ me.context.value = value;
+ me.fireEvent('edit', me, me.context);
+
- if (!me.validateEdit()) {
- return;
}
- me.context.record.set(dataIndex, value);
- me.fireEvent('edit', me, me.context);
},
- /**
+ /**
* Cancel any active editing.
*/
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);
@@ -347,7 +393,7 @@ grid.on('validateedit', function(e) {
}
},
- /**
+ /**
* Starts editing by position (row/column)
* @param {Object} position A position with keys of row and column.
*/
@@ -363,4 +409,6 @@ grid.on('validateedit', function(e) {
}
me.startEdit(editRecord, editColumnHeader);
}
-});
\ No newline at end of file
+});
+
+