当前位置:编程学习 > JS >>

Extjs4---鼠标右键事件

在Extjs4中鼠标的右键相应事件为
itemcontextmenu( Ext.view.View this, Ext.data.Model record,
 HTMLElement item, Number index, Ext.EventObject e, Object eOpts )
使用时直接在listeners中添加即可:

[javascript] 
listeners:{ 
                'itemcontextmenu':function(view,record,item,index,e,eOpts){ 
                    //禁用浏览器的右键相应事件 
                    e.preventDefault(); 
                    e.stopEvent(); 
                     
                    var menu = new Ext.menu.Menu({ 
                        //控制右键菜单位置 
                        float:true, 
                         items:[{ 
                                text:"修改", 
                                iconCls:'leaf', 
                                handler:function(){ 
                                    //当点击时隐藏右键菜单 
                                    this.up("menu").hide(); 
                                    alert(record.raw.name); 
                                } 
                            },{ 
                                text:"添加", 
                                iconCls:'leaf', 
                                handler:function(){ 
                                    this.up("menu").hide(); 
                                    alert("添加"); 
                                } 
                            },{ 
                                text:"删除", 
                                iconCls:'leaf', 
                                handler:function(){ 
                                    this.up("menu").hide(); 
                                    alert("删除"); 
                                } 
                            } 
                         ] 
                    }).showAt(e.getXY());//让右键菜单跟随鼠标位置 
                } 
            } 

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,