i need right ckicked menu. - Ext JS

本文介绍如何在ExtJS网格中实现自定义右键点击事件,包括创建事件监听器及显示上下文菜单的具体步骤。
i need right ckicked menu when right click row in the grid.how do?
Reply With Quote
  #2  
Old 03-13-2007, 08:55 AM
DefaultRe: i need right ckicked menu.

Quote:
Originally Posted by melin
i need right ckicked menu when right click row in the grid.how do?
Well, once you've created your grid:

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]]);
  }
That's about it, good luck!
-Eric
Reply With Quote
  #3  
Old 03-14-2007, 09:56 AM
Default

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?!
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值