Code:
Ext.create('Ext.data.Store', {
storeId:'employeeStore',
fields:['firstname', 'lastname', 'seniority', 'dep', 'hired'],
data:[
{firstname:"Michael", lastname:"Scott"},
{firstname:"Dwight", lastname:"Schrute"},
{firstname:"Jim", lastname:"Halpert"},
{firstname:"Kevin", lastname:"Malone"},
{firstname:"Angela", lastname:"Martin"}
]
});
var p = Ext.create('Ext.grid.Panel', {
title: 'Action Column Demo',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{text: 'First Name', dataIndex:'firstname'},
{text: 'Last Name', dataIndex:'lastname'},
{
xtype:'actioncolumn',
width:50,
items: [{
icon: 'http://raymanpc.com/wiki/images/thumb/2/2f/GreenTick.png/20px-GreenTick.png',
handler: function(v, row, col, item, e, rec) {
MyApp.app.fireEvent('actionclick', v, row, col, item, e, rec);
}
}]
}
],
width: 250
});
Ext.define('MyApp.controller.Users', {
extend: 'Ext.app.Controller',
init: function() {
var me = this;
me.application.on('actionclick', me.onActioncolumnClick);
}
, onActioncolumnClick: function (v, row, col, item, e, rec) {
console.log(rec);
}
});
Ext.application({
name: 'MyApp',
controllers: ['Users'],
init: function () {
MyApp.app = this;
},
launch: function() {
this.addEvents('actionclick');
Ext.create('Ext.container.Viewport', {
layout: 'fit'
,items: [p]
});
}
});