EXTJS 5的ACTION COLUMN好像没有文字的,所以自已改了一小点原来的代码。湊和起用吧,只能说。
/** * 带文字和图标的action column * * * @author <a href='mailto:xiaomingyang@aksl.com.cn'>xiaomingyang</a> 2016-01-19,17:08 * @version v0.1 */ Ext.define('Ext.grid.column.ActionText', { extend: 'Ext.grid.column.Column', alias: [ 'widget.actionTextcolumn' ], xtype : 'actionTextColumn', alternateClassName: 'Ext.grid.ActionTextColumn', stopSelection: true, actionIdRe: new RegExp(Ext.baseCSSPrefix + 'action-col-(\\d+)'), altText: '', menuText: '<i>操作</i>', sortable: false, innerCls: Ext.baseCSSPrefix + 'grid-cell-inner-actiontext-col', actionIconCls: Ext.baseCSSPrefix + 'action-col-icon', constructor: function(config) { var me = this, cfg = Ext.apply({}, config), items = cfg.items || me.items || [ me ], hasGetClass, i, len; me.origRenderer = cfg.renderer || me.renderer; me.origScope = cfg.scope || me.scope; me.renderer = me.scope = cfg.renderer = cfg.scope = null; cfg.items = null; me.callParent([ cfg ]); me.items = items; for (i = 0 , len = items.length; i < len; ++i) { if (items[i].getClass) { hasGetClass = true; break; } } if (me.origRenderer || hasGetClass) { me.hasCustomRenderer = true; } }, initComponent: function() { var me = this; me.callParent(); if (me.sortable && !me.dataIndex) { me.sortable = false; } }, defaultRenderer: function(v, cellValues, record, rowIdx, colIdx, store, view) { var me = this, prefix = Ext.baseCSSPrefix, scope = me.origScope || me, items = me.items, len = items.length, i = 0, j = 0, item, ret, disabled, tooltip; ret = Ext.isFunction(me.origRenderer) ? me.origRenderer.apply(scope, arguments) || '' : ''; cellValues.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell'; for (; i < len; i++) { item = items[i]; disabled = item.disabled || (item.isDisabled ? item.isDisabled.call(item.scope || scope, view, rowIdx, colIdx, item, record) : false); tooltip = disabled ? null : (item.tooltip || (item.getTip ? item.getTip.apply(item.scope || scope, arguments) : null)); if (!item.hasActionConfiguration) { 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; } //ret += '<img role="button" alt="' + (item.altText || me.altText) + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) + '" class="' + me.actionIconCls + ' ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + (tooltip ? ' data-qtip="' + tooltip + '"' : '') + ' />'; var spacesStr = ''; if (item.spaces) { for (var si = 0; si < item.spaces; si++) { spacesStr += ' '; } } var iconStr = '<div style="float:left;"><a href="#" class="x-action-col-' + String(j) + '"><img role="button" alt="' + (item.altText || me.altText) + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) + '" class="' + me.actionIconCls + ' ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + (tooltip ? ' data-qtip="' + tooltip + '"' : '') + ' />' + item.showText + '</a>' + spacesStr + '</div>'; ret += iconStr; j++; } return ret; }, updater: function(cell, value, record, view, dataSource) { var cellValues = {}; cell.firstChild.innerHTML = this.defaultRenderer(value, cellValues, record, null, null, dataSource, view); Ext.fly(cell).addCls(cellValues.tdCls); }, enableAction: function(index, silent) { var me = this; if (!index) { index = 0; } else if (!Ext.isNumber(index)) { index = Ext.Array.indexOf(me.items, index); } me.items[index].disabled = false; me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).removeCls(me.disabledCls); if (!silent) { me.fireEvent('enable', me); } }, disableAction: function(index, silent) { var me = this; if (!index) { index = 0; } else if (!Ext.isNumber(index)) { index = Ext.Array.indexOf(me.items, index); } me.items[index].disabled = true; me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).addCls(me.disabledCls); if (!silent) { me.fireEvent('disable', me); } }, beforeDestroy: function() { this.renderer = this.items = null; return this.callParent(arguments); }, processEvent: function(type, view, cell, recordIndex, cellIndex, e, record, row) { var me = this, target = e.getTarget(), key = type === 'keydown' && e.getKey(), match, item, disabled; if (key && !Ext.fly(target).findParent(view.getCellSelector())) { target = Ext.fly(cell).down('.' + Ext.baseCSSPrefix + 'action-col-icon', true); } if (target && (match = target.className.match(me.actionIdRe))) { item = me.items[parseInt(match[1], 10)]; disabled = item.disabled || (item.isDisabled ? item.isDisabled.call(item.scope || me.origScope || me, view, recordIndex, cellIndex, item, record) : false); if (item && !disabled) { if (type === 'mousedown') { if (item.stopSelection) { e.preventDefault(); } return false; } if (type === 'click' || (key === e.ENTER || key === e.SPACE)) { Ext.callback(item.handler || me.handler, item.scope || me.origScope, [ view, recordIndex, cellIndex, item, e, record, row ], undefined, me); if (item.stopSelection !== false) { return false; } } } } return me.callParent(arguments); }, cascade: function(fn, scope) { fn.call(scope || this, this); }, getRefItems: function() { return []; }, privates: { getFocusables: function() { return []; } } });
用例代码:
{ xtype:'actionTextColumn', text : '操作', flex : 2, items: [{ iconCls : 'ext-grid-column-actionColumn-iconEdit', showText : '修改', tooltip : '修改角色', spaces : 3, handler: function(grid, rowIndex, colIndex, item, e, record) { var rec = grid.getStore().getAt(rowIndex); _this._editRoleItem(rec); } }, { iconCls : 'ext-grid-column-actionColumn-iconView', showText : '查看', tooltip : '查看角色', spaces : 3, handler: function(grid, rowIndex, colIndex, item, e, record) { var rec = grid.getStore().getAt(rowIndex); _this._viewRoleItem(rec); } }, { iconCls : 'ext-grid-column-actionColumn-iconDelete', showText : '删除', tooltip : '删除角色', handler: function(grid, rowIndex, colIndex, item, e, record) { var rec = grid.getStore().getAt(rowIndex); _this._deleteRoleItem(rec); } }] }
相关推荐
李白高力士脱靴李白贺知章告别课本剧.pptx
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
C语言项目之超级万年历系统源码,可以做课程设计参考 文章参考:https://www.qqmu.com/4373.html
Jupyter-Notebook
51单片机加减乘除计算器系统设计(proteus8.17,keil5),复制粘贴就可以运行
《中国房地产统计年鉴》面板数据资源-精心整理.zip
Jupyter-Notebook
Jupyter-Notebook
毕业论文答辩ppt,答辩ppt模板,共18套
Jupyter-Notebook
《中国城市统计年鉴》面板数据集(2004-2020年,最新).zip
Python基础 本节课知识点: • set的定义 • Set的解析 • set的操作 • set的函数
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
兵制与官制研究资料最新版.zip
Jupyter-Notebook
七普人口数据+微观数据+可视化+GIS矢量资源-精心整理.zip
Support package for Hovl Studio assets.unitypackage
土壤数据库最新集.zip
Jupyter-Notebook
1991-2020年中国能源统计年鉴-能源消费量(分省)面板数据-已更至最新.zip