分享

Extjs4

 馆天下ccf 2014-09-05

在Extjs4中鼠标的右键相应事件为

itemcontextmenuExt.view.View this, Ext.data.Model record, HTMLElement item, Number index, Ext.EventObject e, Object eOpts )

使用时直接在listeners中添加即可:


[javascript] view plaincopy
  1. listeners:{  
  2.                 'itemcontextmenu':function(view,record,item,index,e,eOpts){  
  3.                     //禁用浏览器的右键相应事件  
  4.                     e.preventDefault();  
  5.                     e.stopEvent();  
  6.                       
  7.                     var menu = new Ext.menu.Menu({  
  8.                         //控制右键菜单位置  
  9.                         float:true,  
  10.                          items:[{  
  11.                                 text:"修改",  
  12.                                 iconCls:'leaf',  
  13.                                 handler:function(){  
  14.                                     //当点击时隐藏右键菜单  
  15.                                     this.up("menu").hide();  
  16.                                     alert(record.raw.name);  
  17.                                 }  
  18.                             },{  
  19.                                 text:"添加",  
  20.                                 iconCls:'leaf',  
  21.                                 handler:function(){  
  22.                                     this.up("menu").hide();  
  23.                                     alert("添加");  
  24.                                 }  
  25.                             },{  
  26.                                 text:"删除",  
  27.                                 iconCls:'leaf',  
  28.                                 handler:function(){  
  29.                                     this.up("menu").hide();  
  30.                                     alert("删除");  
  31.                                 }  
  32.                             }  
  33.                          ]  
  34.                     }).showAt(e.getXY());//让右键菜单跟随鼠标位置  
  35.                 }  
  36.             }  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约