I am trying to show a menu in a grid panel. I have a actioncolumn to display an icon and i want apply an effect... when the mouse is over that icon, a menu will be displayed.
How i can do this in extjs 5?
My actioncolumn is this:
{
xtype: 'actioncolumn',
width: 70,
items: [{
icon: 'resources/images/icons/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(grid, rowIndex, colIndex, a, b, c) {
}
}]
}
Referring to this post that I mentioned in the comments, your solution may look something like this:
var menu_grid = new Ext.menu.Menu({
items: [
{ text: 'Add', handler: function() {console.log("Add");} },
{ text: 'Delete', handler: function() {console.log("Delete");} }
]
});
...
{
xtype: 'actioncolumn',
width: 70,
items: [{
icon: 'resources/images/icons/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(grid, rowIndex, colIndex, item, e, record) {
var position = e.getXY();
e.stopEvent();
menu_grid.showAt(position);
}
}]
}
EDIT: Be careful creating items like this, when they are hidden they are not removed completely and can cause memory leaks, refer to this post for further information and possible workarounds/solutions.