Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    Tbilisi, Georgia
    Posts
    3
    Vote Rating
    0
    Zura is on a distinguished road

      0  

    Default 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
    Browser versions tested against:
    • Chrome 24.0.1312.52
    • FF18 (firebug 1.11.1 installed)
    Description:
    • When use itemdblclick and itemcontextmenu events on grid, itemcontextmenu is firing, but itemdblclick stops working. when I deleted itemcontextmenu event itemdblclick starts working again
    Steps to reproduce the problem:
    • create simple grid with store
    • create controller with events itemcontextmenu and itemdblclick
    The result that was expected:
    • both events must fire
    The result that occurs instead:
    • Only itemcontextmenu is firing
    Test Case:


    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
    Possible fix:
    • 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');
          }
      });
    Additional CSS used:
    • only default ext-all.css
    • custom css (include details)
    Operating System:
    • Win 8

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,656
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Take a look at this (from your code):

    Code:
    this.control({
        "#mainGrid" : {
            itemdblclick : this.griditemdbclick
        },
        "#mainGrid" : {
            itemcontextmenu : this.onrightclick
        }
    });
    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,
            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.