开发者

Extjs context menu (right click) on a button

开发者 https://www.devze.com 2023-01-30 15:35 出处:网络
I would like to know how to put an Extjs Context Menu (Right Click) onto a button. 开发者_如何学编程

I would like to know how to put an Extjs Context Menu (Right Click) onto a button.

开发者_如何学编程

I have searched google but all I seem to get is how to put it onto a TreePanel. I have tried a similar approach to the TreePanel with buttons but with no luck.


The context menu is just floating menu, so just grab the context menu event and show the menu. Since the button doesn't have the contextmenu you can grab directly the htmlelement (or the Element wrapper) and listen to the contextmenu event

example:

contextMenu = new Ext.menu.Menu({
  items: [{
    text: 'Edit',
    iconCls: 'edit',
    handler: edit
  }]
});

Ext.getCmp('your-button').getEl().on('contextmenu', function(e) {
     e.preventDefault();
     contextMenu.show(Ext.getCmp('your-button').getEl());
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号