X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/docs/source/EditorGrid.html diff --git a/docs/source/EditorGrid.html b/docs/source/EditorGrid.html index 73d5d358..2622eec9 100644 --- a/docs/source/EditorGrid.html +++ b/docs/source/EditorGrid.html @@ -1,5 +1,6 @@ + The source code @@ -152,16 +153,25 @@ grid.on('validateedit', function(e) { initEvents : function(){ Ext.grid.EditorGridPanel.superclass.initEvents.call(this); - this.on("bodyscroll", this.stopEditing, this, [true]); - this.on("columnresize", this.stopEditing, this, [true]); + this.getGridEl().on('mousewheel', this.stopEditing.createDelegate(this, [true]), this); + this.on('columnresize', this.stopEditing, this, [true]); if(this.clicksToEdit == 1){ this.on("cellclick", this.onCellDblClick, this); }else { - if(this.clicksToEdit == 'auto' && this.view.mainBody){ - this.view.mainBody.on("mousedown", this.onAutoEditClick, this); + var view = this.getView(); + if(this.clicksToEdit == 'auto' && view.mainBody){ + view.mainBody.on('mousedown', this.onAutoEditClick, this); } - this.on("celldblclick", this.onCellDblClick, this); + this.on('celldblclick', this.onCellDblClick, this); + } + }, + + onResize : function(){ + Ext.grid.EditorGridPanel.superclass.onResize.apply(this, arguments); + var ae = this.activeEditor; + if(this.editing && ae){ + ae.realign(true); } }, @@ -175,8 +185,8 @@ grid.on('validateedit', function(e) { if(e.button !== 0){ return; } - var row = this.view.findRowIndex(t); - var col = this.view.findCellIndex(t); + var row = this.view.findRowIndex(t), + col = this.view.findCellIndex(t); if(row !== false && col !== false){ this.stopEditing(); if(this.selModel.getSelectedCell){ // cell sm @@ -196,9 +206,9 @@ grid.on('validateedit', function(e) { onEditComplete : function(ed, value, startValue){ this.editing = false; this.activeEditor = null; - ed.un("specialkey", this.selModel.onEditorKey, this.selModel); - var r = ed.record; - var field = this.colModel.getDataIndex(ed.col); + + var r = ed.record, + field = this.colModel.getDataIndex(ed.col); value = this.postEditValue(value, startValue, r, field); if(this.forceValidation === true || String(value) !== String(startValue)){ var e = { @@ -229,17 +239,17 @@ grid.on('validateedit', function(e) { this.stopEditing(); if(this.colModel.isCellEditable(col, row)){ this.view.ensureVisible(row, col, true); - var r = this.store.getAt(row); - var field = this.colModel.getDataIndex(col); - var e = { - grid: this, - record: r, - field: field, - value: r.data[field], - row: row, - column: col, - cancel:false - }; + var r = this.store.getAt(row), + field = this.colModel.getDataIndex(col), + e = { + grid: this, + record: r, + field: field, + value: r.data[field], + row: row, + column: col, + cancel:false + }; if(this.fireEvent("beforeedit", e) !== false && !e.cancel){ this.editing = true; var ed = this.colModel.getCellEditor(col, row); @@ -247,22 +257,35 @@ grid.on('validateedit', function(e) { return; } if(!ed.rendered){ - ed.render(this.view.getEditorParent(ed)); + ed.parentEl = this.view.getEditorParent(ed); + ed.on({ + scope: this, + render: { + fn: function(c){ + c.field.focus(false, true); + }, + single: true, + scope: this + }, + specialkey: function(field, e){ + this.getSelectionModel().onEditorKey(field, e); + }, + complete: this.onEditComplete, + canceledit: this.stopEditing.createDelegate(this, [true]) + }); } - (function(){ // complex but required for focus issues in safari, ie and opera - ed.row = row; - ed.col = col; - ed.record = r; - ed.on("complete", this.onEditComplete, this, {single: true}); - ed.on("specialkey", this.selModel.onEditorKey, this.selModel); -
/** - * The currently active editor or null - * @type Ext.Editor - */ - this.activeEditor = ed; - var v = this.preEditValue(r, field); - ed.startEdit(this.view.getCell(row, col).firstChild, v === undefined ? '' : v); - }).defer(50, this); + Ext.apply(ed, { + row : row, + col : col, + record : r + }); + this.lastEdit = { + row: row, + col: col + }; + this.activeEditor = ed; + var v = this.preEditValue(r, field); + ed.startEdit(this.view.getCell(row, col).firstChild, Ext.isDefined(v) ? v : ''); } } }, @@ -270,12 +293,12 @@ grid.on('validateedit', function(e) { // private preEditValue : function(r, field){ var value = r.data[field]; - return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlDecode(value) : value; + return this.autoEncode && Ext.isString(value) ? Ext.util.Format.htmlDecode(value) : value; }, // private postEditValue : function(value, originalValue, r, field){ - return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value; + return this.autoEncode && Ext.isString(value) ? Ext.util.Format.htmlEncode(value) : value; },
/** @@ -283,10 +306,15 @@ grid.on('validateedit', function(e) { * @param {Boolean} cancel (optional) True to cancel any changes */ stopEditing : function(cancel){ - if(this.activeEditor){ - this.activeEditor[cancel === true ? 'cancelEdit' : 'completeEdit'](); + if(this.editing){ + var ae = this.activeEditor; + if(ae){ + ae[cancel === true ? 'cancelEdit' : 'completeEdit'](); + this.view.focusCell(ae.row, ae.col); + } + this.activeEditor = null; } - this.activeEditor = null; + this.editing = false; } }); Ext.reg('editorgrid', Ext.grid.EditorGridPanel);