Search code examples
gridviewextjscontextmenuextjs4.1gridpanel

Extjs 4.1.1 linking a contextmenu to a grid


Using Extjs 4.1.1

I am attempting to link a contextmenu (right click initiated menu) to a grid. So, I have the Ext.menu.menu and when a user right clicks my grid I want to display the menu using showAt. This works to a degree...

However, I need to actions of the contextmenu, which are identical to the actions in a toolbar menu of the same page, to be linked to the grid. So, I need the contextmenu options to actually do something. The way I have found to do this is by 'docking' the menu

this.addDocked(this.contextMenu);

where this is the grid, and I have created a menu named contextMenu.

the issue with this is that it messes up the layout. The contextmenu usually pops up halfway off of the bottom of the screen, regardless of what I specify in showAt(). Also on one of the sides, the layout creates a blank space, I guess where it would 'dock' the contextmenu. However, I don't truly want it docked, I want it floating like a true right-click menu.

So, the question is: How do I link the menu to the grid without runing the layout by docking?


Solution

  • Check out the Simple Tasks demo that ships with the release. It uses these exact concepts you are trying to implement.