PDA

View Full Version : containercontextmenu event in EditorGrid



aj3423
2 Sep 2010, 8:06 PM
right clicking in a grid cell

// private
processEvent : function(name, e) {
var t = e.getTarget(),
g = this.grid,
header = this.findHeaderIndex(t);
g.fireEvent(name, e);
if (header !== false) {
g.fireEvent('header' + name, g, header, e);
} else {
var row = this.findRowIndex(t), // <------------ this line
cell,
body;
if (row !== false) {
g.fireEvent('row' + name, g, row, e);
cell = this.findCellIndex(t);
if (cell !== false) {
g.fireEvent('cell' + name, g, row, cell, e);
} else {
body = this.findRowBody(t);
if (body) {
g.fireEvent('rowbody' + name, g, row, e);
}
}
} else {
g.fireEvent('container' + name, g, e);
}
}
},


var row = this.findRowIndex(t), // this always return false in case of EditorGrid because the cell isn't a standard grid cell, may be a spinner
if (row !== false) { // so the 'rowcontextmenu' and 'cellcontextmenu' won't excute, always comes a 'containercontextmenu'

anyway to fix this?

aj3423
2 Sep 2010, 11:19 PM
after I tried sometimes, I got it work with this hotfix:

processEvent : function(name, e) {
var t = e.getTarget(),
g = this.grid,
header = this.findHeaderIndex(t);
g.fireEvent(name, e);
if (header !== false) {
g.fireEvent('header' + name, g, header, e);
} else {
if(this.grid.editing) { // <--------------- if is an EditorGrid and is editing, just return
return;
}
var row = this.findRowIndex(t),

Condor
3 Sep 2010, 12:47 AM
Are you clicking on the grid (in which case the event should fire) or on the editor (in which case you have to catch the event in the editor and not in the grid)?

aj3423
3 Sep 2010, 1:44 AM
I'm using a TextField in the cell and followed these steps:
1. click on the TextField to get into edit mode
2. right click in the editor

with the right click:
'rowcontextmenu' and 'cellcontextmenu' not fired
'containercontextmenu' is fired

Condor
3 Sep 2010, 1:47 AM
As I said, these only fire when you click on the grid. The editor is completely separate from the grid and has it's own events.

aj3423
3 Sep 2010, 2:02 AM
but I think the grid shouldn't fire containercontextmenu when right clicking in the cell

Condor
3 Sep 2010, 2:34 AM
The editor is also rendered to the grid scroller, so it is technically outside any row and within the container.

You can change this by specifying a different editor parent in your viewConfig, e.g.

viewConfig: {
getEditorParent: function(){
return Ext.getBody().dom;
}
}

aj3423
3 Sep 2010, 3:17 AM
in GridView.js I see

getEditorParent : function(){
return this.scroller.dom;
},
why not return Ext.getBody().dom; by default?
I'll try this patch later to see if there are side effects.
Thank you Condor