-
22 Jan 2013 5:15 AM #1
Firing itemcontextmenu and itemdblclick events on grid with controller
Firing itemcontextmenu and itemdblclick events on grid with controller
REQUIRED INFORMATION
Ext version tested:- Ext 4.0.7
- Ext 4.1.1
- Chrome 24.0.1312.52
- FF18 (firebug 1.11.1 installed)
- When use itemdblclick and itemcontextmenu events on grid, itemcontextmenu is firing, but itemdblclick stops working. when I deleted itemcontextmenu event itemdblclick starts working again
- create simple grid with store
- create controller with events itemcontextmenu and itemdblclick
- both events must fire
- Only itemcontextmenu is firing
Grid
Code:Ext.define('MyApp.view.MyGridPanel', { extend: 'Ext.grid.Panel', id: 'mainGrid', title: 'Test Grid Panel', store: 'MyStore', initComponent: function() { var me = this; Ext.applyIf(me, { columns: [ { xtype: 'gridcolumn', dataIndex: 'id', text: 'ID' }, { xtype: 'booleancolumn', dataIndex: 'name', text: 'Value' } ] }); me.callParent(arguments); } });
Store
Code:xt.define('MyApp.store.MyStore', { extend: 'Ext.data.Store', constructor: function(cfg) { cfg = cfg || {}; me.callParent([Ext.apply({ storeId: 'MyStore', data: [ { id: 1, name: 'true' }, { id: 2, name: 'false' } ], fields: [ { name: 'id' }, { name: 'name' } ] }, cfg)]); } });
Controller
Code:extend: 'Ext.app.Controller', init: function(application) { this.control({ "#mainGrid": { itemdblclick: this.griditemdbclick }, "#mainGrid": { itemcontextmenu: this.onrightclick } }); }, griditemdbclick: function(target) { alert("Fired itemDBlclick Event"); }, onrightclick: function(target) { alert('Fired itemcontextmenu Event'); } });
HELPFUL INFORMATION
Debugging already done:- none
- well, it's not a fix but if both or for example "itemcontextmenu" event is written in view instead of controller everything works.
Grid
Code:Ext.define('MyApp.view.MyGridPanel', { extend: 'Ext.grid.Panel', id: 'mainGrid', title: 'Test Grid Panel', store: 'MyStore', initComponent: function() { var me = this; Ext.applyIf(me, { columns: [ { xtype: 'gridcolumn', dataIndex: 'id', text: 'ID' }, { xtype: 'booleancolumn', dataIndex: 'name', text: 'Value' } ], listeners: { containercontextmenu: { fn: me.onMainGridContainerContextMenu, scope: me } } }); me.callParent(arguments); }, onMainGridContainerContextMenu: function(tablepanel, e, options) { alert('Fired itemcontextmenu Event'); } });
- only default ext-all.css
- custom css (include details)
- Win 8
-
22 Jan 2013 7:26 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Take a look at this (from your code):
You cannot have the same properties ("#mainGrid") in an object, JavaScript will use the last one but not the ones before it. Try this:Code:this.control({ "#mainGrid" : { itemdblclick : this.griditemdbclick }, "#mainGrid" : { itemcontextmenu : this.onrightclick } });
Code:this.control({ "#mainGrid" : { itemdblclick : this.griditemdbclick, itemcontextmenu : this.onrightclick } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote