extjs5 - ExtJS: How bind context menu action in controller? -


fiddle: https://fiddle.sencha.com/#fiddle/q02

ext.define('econtroller', {     extend: 'ext.app.viewcontroller',     alias: 'controller.test',      control: {         '#myaction': {             click: function() {                 alert('my action')             }         }     } });    var sellaction = ext.create('ext.action', {         text: 'my action',         itemid: 'myaction'     });     var contextmenu = ext.create('ext.menu.menu', {         items: [             sellaction         ]     });  var grid = ext.create('ext.grid.panel', {         controller:'test', ...................................         dockeditems: [{             xtype: 'toolbar',             items: [                 sellaction             ]         }], 

alert fires in toolbar button, not work in context menu.

how add same listener context menu button , toolbar button? (best way)

you can't. because, unlike toolbar, context menu not part of grid — shown grid @ e.getxy(). therefore control directive cannot reach context menu.

an alternative use action handlers instead of controller's control:

var sellaction = ext.create('ext.action', {     text: 'my action',     itemid: 'myaction',     handler: function() {         alert('my action')     } }); 

fiddle fork: https://fiddle.sencha.com/#fiddle/q0d


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -