发布网友 发布时间:2022-04-27 02:29
共2个回答
热心网友 时间:2022-06-24 19:55
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,
defaultRenderer : function (v, meta) {
var me = this,
prefix = Ext.baseCSSPrefix,
scope = me.origScope || me,
items = me.items,
len = items.length,
i = 0,
item;
// Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!)
v = Ext.isFunction(me.origRenderer) ? me.origRenderer.apply(scope, arguments) || '' : '';
meta.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell';
for (; i < len; i++) {
item = items[i];
// Only process the item action setup once.
if (!item.hasActionConfiguration) {
// Apply our documented default to all items
item.stopSelection = me.stopSelection;
item.disable = Ext.Function.bind(me.disableAction, me, [i], 0);
item.enable = Ext.Function.bind(me.enableAction, me, [i], 0);
item.hasActionConfiguration = true;
}
v += '<img alt="' + (item.altText || me.altText) + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) +
'" class="' + prefix + 'action-col-icon ' + prefix + 'action-col-' + String(i) + ' ' + (item.disabled ? prefix + 'item-disabled' : ' ') +
' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' +
((item.tooltip) ? ' data-qtip="' + item.tooltip + '"' : '') + ' />';
}
return v;
},
items : [{
icon : 'extjs/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
tooltip : 'Edit',
handler : function (grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Edit " + rec.get('firstname'));
}
}, {
icon : 'extjs/examples/restful/images/delete.png',
tooltip : 'Delete',
handler : function (grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Terminate " + rec.get('firstname'));
}
}
]
}
],
width : 250,
renderTo : Ext.getBody()
});
可以在“操作列”那重载他的defaultRenderer函数
最好的方式是直接重载Ext-grid-column-Action的defaultRenderer函数,在里面添加事件判断什么的
热心网友 时间:2022-06-24 19:56
隐藏'srusyti、