How i can create context menu for extjs grid

前端 未结 5 446
我寻月下人不归
我寻月下人不归 2021-02-04 03:08

I can create context menu for tree and attach to \'contextmenu\' event. Code:

contextMenu = new Ext.menu.Menu({
  items: [{
    text: \'Edit\',
    iconCls: \'ed         


        
5条回答
  •  野性不改
    2021-02-04 03:24

    First define your context menu

    mnuContext = new Ext.menu.Menu({
        items: [{
            id: 'do-something',
            text: 'Do something'
        }],
        listeners: {
            itemclick: function(item) {
                switch (item.id) {
                    case 'do-something':
                        break;
                }
            }
        }
    });
    

    Then create a listener for the desired event. It is very important to remember to stop the event's default behaviour so you can replace it with your own. If you don't call the event.stopEvent() method to stop the event bubbling onwards then the brower's default context menu will appear regardless of what you do.

    rowcontextmenu: function(grid, index, event){
         event.stopEvent();
         mnuContext.showAt(event.xy);
    }
    

提交回复
热议问题