ExtJS grid: handling action column's click event in the controller

后端 未结 1 1032
遇见更好的自我
遇见更好的自我 2021-01-14 06:14

I have a view \'EmployeeList\'. Inside it there is a grid. I need to handle the actioncolumn\'s click event from controller. Here is the view:

Ext.define(\'E         


        
相关标签:
1条回答
  • 2021-01-14 06:38

    If you wanna handle the clicks with your controller, you will have to add a handler to your actioncolumn like this:

    xtype:'actioncolumn',
    width:50,
    items: [{
        icon: 'extjs/examples/shared/icons/fam/cog_edit.png',  // Use a URL in the icon config
        tooltip: 'Edit',
        handler: function(view, rowIndex, colIndex, item, e, record, row) {
            this.fireEvent('itemClick', view, rowIndex, colIndex, item, e, record, row, 'edit');
        }
    }]
    

    And then add event handler in your controller for the itemClick event

    init: function() {
        this.control({
             'actioncolumn': {
                 itemClick: this.onActionColumnItemClick
             }
         });
    },
    onActionColumnItemClick : function(view, rowIndex, colIndex, item, e, record, row, action) {
        alert(action + " user " + record.get('firstname'));
    }
    

    And you should see it working, fiddle here: https://fiddle.sencha.com/#fiddle/grb

    0 讨论(0)
提交回复
热议问题