在ExtJs4中,grid组件有Ext.grid.column.Action组件,所有要增加操作列,只需指定列的xtype为actioncolumn即可,例如:
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
width: 500,
height: 400,
store: Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
data: [
{id: '1', name: '张三'},
{id: '2', name: '李四'}
]
}),
columns: [
{text: '姓名', dataIndex: 'name', flex: 1},
{
xtype: 'actioncolumn',
text: '操作',
width: 100,
tdCls: 'action',
items: [{
icon: 'images/edit.png',
tooltip: '编辑',
handler: function (grid, rowIndex, colIndex, node, e, record, rowEl) {
// do something...
}
}, {