0

I have following code

grid.on('contextmenu', this.onContextMenu, this);

onContextMenu: function (e) {
      // I want the grid here
    },

there is only one argument 'e'. I cannot use 'this' as the grid is inside panel and 'this' returns panel not the grid. I am using Extjs 2.3.0.

CD..
  • 72,281
  • 25
  • 154
  • 163
Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
  • Hmm, are you sure you want contextmenu and not one of the others like rowcontextmenu or cellcontextmenu? Even with contextmenu, though, you have the event object. You should be able to get the target of the contextmenu event and use it as a starting place for traversing the dom upward to find the base grid element. Alternatively, you could also give your grid an id and just use Ext.getCmp(...) – existdissolve May 30 '13 at 13:02
  • Yes, I want contextmenu only and not rowcontextmenu and others... Also, I can’t use id of grid as I am creating four different grids using same function and in that function I am calling this code for contxtmenu. I was thinking just like ‘e’ there should be an argument as ‘grid’ just like rowcontextmenu(grid, index, event)… – Microsoft DN May 30 '13 at 13:19
  • Okay, then the other option is the way to go. – existdissolve May 30 '13 at 13:28

1 Answers1

0

You can pass the grid to your handler yourself:

grid.on('contextmenu', function(e) {
    this.onContextMenu(e, grid);
}, this);

Your handler method:

onContextMenu: function(e, grid) {
    // have fun with your grid
}
rixo
  • 23,815
  • 4
  • 63
  • 68