Reputation: 1719
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('ExtApp.view.Employees', {
extend: 'Ext.panel.Panel',
alias: 'widget.employees',
.
.
.
.
.
});
This view contains a grid:
xtype: 'grid',
columns:[{
.
.
.
.
xtype: 'actioncolumn',
text: 'Delete',
width: 100,
items: [{
icon: 'images/deleteEmployee.jpg',
tooltip: 'Delete'
}]
}]
How do I handle the actioncolumn's click event in my controller?
Here is the controller's code:
Ext.define('ExtApp.controller.Employees', {
extend: 'Ext.app.Controller',
refs: [{
ref: 'employees',
selector: 'employees'
}],
init: function () {
//reference for the grid's actioncolumn needed here
}
});
Upvotes: 3
Views: 13508
Reputation: 4760
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
Upvotes: 9