[ACCEPTED]-How to add row double click event listener when extending grid panel with Ext.define()?-extjs4

Accepted answer
Score: 26

You don't need to put the listener in the 11 viewconfig. Here is my working configuration:

listeners : {
    itemdblclick: function(dv, record, item, index, e) {
        alert('working');
    }
},

Another 10 thing is, you seems to have used Ext.grid.GridPanel in the 9 extend property. But in documentation it's 8 Ext.grid.Panel. But even with gridpanel, everything seems 7 to work fine.

I would suggest to use the 6 Ext JS 4 terms as it might cause to application 5 breakage later in other 4.x versions.

Now, if 4 you are using the new MVC architecture, you 3 will want to move these actions to the controller 2 rather than the view. You can refer to the 1 MVC Architecture guide for details.

Score: 2

With the MVC approach in ExtJS 4 there's 2 another smart way too to define such handlers. Some 1 example code:

Ext.define('App.controller.Documents', {

  extend: 'Ext.app.Controller',
  stores: ['Documents'],
  models: ['Document'],
  views: [
    'document.List',
    'document.Edit',
    'document.Preview'
  ],  

  init: function() {

    this.control({

      /*  
       * a cool way to select stuff in ExtJS 4
       */
      'documentlist': {
        itemdblclick: this.editDocument
      },  

      /*  
       * simple access to components
       */
      'documentedit button[action=save]': {
        click: this.updateDocument
      },  

    }); 

  },  

  editDocument: function(grid, record) {
    var view = Ext.widget('documentedit');
    view.down('form').loadRecord(record);
  },  

  updateDocument: function(button) {
    var win = button.up('window'),  // new selection API
        form   = win.down('form'),  // in ExtJS 4
        record = form.getRecord(),
        values = form.getValues();

    record.set(values);
    win.close();
  }
});
Score: 0
listeners: {
        select: 'xxxx',

        itemdblclick: function (dv, record, item, index, e) {
            var myBtn = Ext.getCmp('btnEdit');
            myBtn.onClick();
        }
    },

0

More Related questions