i need right ckicked menu when right click row in the grid.how do?

|
#2
| |
|
Quote:
var grid = new Ext.grid.Grid( ... ); You just need to add an event listener for right-click's: grid.addListener('rowcontextmenu', row_context_menu ); Then you'd make a function called 'row_context_menu', along these lines: function row_context_menu(grid, rowIndex, e) {
e.stopEvent() // Stop the click event -- prevent the browsers right click menu from showing, as well as a normal click from registering
var menu = new Ext.menu.Menu( ... ) // Create menu, see the menu example in the resources
menu.add( { text: 'Stuff', handler: function() { alert('Hello') } },
{ text: 'More stuff', handler: function() { alert('World') } } );
// Display the menu where the user clicked
var coords = e.getXY();
menu.showAt([coords[0], coords[1]]);
}
-Eric ![]() |
|
#3
|
|
menu.showAt(...) shows the context menu at the specified location. If you right-click on a row to the far right of a window then the context menu will be causing scrollbars. Maybe menu.showAt(...) should automatically recalculate to show the menu within the viewport?!
![]() |
本文介绍如何在ExtJS网格中实现自定义右键点击事件,包括创建事件监听器及显示上下文菜单的具体步骤。

被折叠的 条评论
为什么被折叠?



