snorbicet
11-26-2008, 10:58 AM
Hello,
How can I add custom menu items to the context menu of a grid's header?
Thanks!
snorbicet
12-10-2008, 10:31 AM
Of course I mean the context menu (not some right-click magic), this:
http://extjs.com/forum/attachment.php?attachmentid=10914&stc=1&d=1228923080
an2ny21
02-23-2010, 10:37 PM
Of course I mean the context menu (not some right-click magic), this:
http://extjs.com/forum/attachment.php?attachmentid=10914&stc=1&d=1228923080
you could add a listeners during the right click event which is the 'contextmenu' and show a menu and then populate
it with the items you want in your context menu.
see my sample code below.
var _grid = new Ext.grid.GridPanel({
store: _store,
enableHdMenu: false,
stripeRows: true,
height: 445,
autoWidth: true,
autoExpandColumn: true,
columns: [
{
header: 'Name',
dataIndex: 'name'
},
{
header: 'Status',
dataIndex: 'status',
}
],
view: new Ext.grid.GroupingView(),
sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
listeners: {
'cellcontextmenu': function(grid, row, col, eventObj){
var _contextMenu = new Ext.menu.Menu({
width: 100,
height: 200,
items: [
{
text: 'test'
}
]
});
_contextMenu.showAt(eventObj.getXY());
}
}
});
an2ny21
02-23-2010, 11:05 PM
don' forget to add this code to disable browser context menu
Ext.getBody().on('contextmenu', function(e){e.stopEvent();});
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.