PDA

View Full Version : EditorGridPanel onCompleteEdit does not fire for pre-rendered editors



sacha
29 Apr 2010, 9:03 AM
I've run into some trouble with the following code in EditorGridPanel (3.2.0):



startEditing: function(row, col) {
...
if(!ed.rendered){
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])
});
}
...


In my case, I have a custom editor panel which is pre-rendered (renderTo: Ext.Body). This is the only way I've been able to allow the editor to overflow the grid, i.e. not be clipped by the grid's boundaries.

However, the above ed.rendered check means that onEditComplete is not called for my editor.

Is there any way I can delay the rendering of my editor so that ed.rendered === false when it hits this code, but still render it to Ext.body()? E.g. is there something I can do in beforerender to change the render target, or is it too late by then?

Or is there a clean alternative? Obviously I could cut and paste the above code and mash it into my code, to make sure all the handlers are set up before the component is rendered, but that's filthy.

sacha
30 Apr 2010, 1:27 AM
In the end, I applied the various handlers to the editor during my grid's columnmodel getCellEditor:


/* There is a problem in that it seems EditorGridPanel expects
* editors to not have yet been rendered. However,
* our CellEditorPanel is pre-rendered to Ext.Body() so that
* it can overflow the grid (i.e. not be clipped by it). So,
* unfortunately, I've had to cut & paste some of the init
* to here.
*/

if (ed && ed instanceof IXCAF.CellEditorPanel && !ed.editorHandlersInitialised) {
// BEGIN cut & paste from EditorGridPanel.onStartEditing
// 'this' replaced with 'grid'
ed.parentEl = grid.view.getEditorParent(ed);
ed.on({
scope: grid,
render: {
fn: function(c){
c.field.focus(false, true);
},
single: true,
scope: grid
},
specialkey: function(field, e){
grid.getSelectionModel().onEditorKey(field, e);
},
complete: grid.onEditComplete,
canceledit: grid.stopEditing.createDelegate(grid, [true])
});
// END
ed.editorHandlersInitialised = true;
}