首页 > 代码库 > override Ext.grid.plugin.RowExpander的方法不起作用
override Ext.grid.plugin.RowExpander的方法不起作用
Ext版本4.2
覆盖方法:
Ext.override(Ext.grid.plugin.RowExpander, { setCmp: function (grid) { var me = this, rowBodyTpl, features; console.log(‘我是盖子。。‘); me.callParent(arguments); me.recordsExpanded = {}; me.rowBodyTpl = Ext.XTemplate.getTpl(me, ‘rowBodyTpl‘); rowBodyTpl = this.rowBodyTpl; features = [{ ftype: ‘rowbody‘, lockableScope: ‘normal‘, recordsExpanded: me.recordsExpanded, rowBodyHiddenCls: me.rowBodyHiddenCls, rowCollapsedCls: me.rowCollapsedCls, setupRowData: me.getRowBodyFeatureData, setup: me.setup, getRowBodyContents: function (record) { return rowBodyTpl.applyTemplate(record); // 修改 } }, { ftype: ‘rowwrap‘, lockableScope: ‘normal‘ }]; if (grid.features) { grid.features = Ext.Array.push(features, grid.features); } else { grid.features = features; } } });
同时,修改ext-all-debug.js中相应的代码如下:
setCmp: function(grid) { var me = this, rowBodyTpl, features; console.log(‘oh my gd!‘); me.callParent(arguments); me.recordsExpanded = {}; me.rowBodyTpl = Ext.XTemplate.getTpl(me, ‘rowBodyTpl‘); rowBodyTpl = this.rowBodyTpl; features = [{ ftype: ‘rowbody‘, lockableScope: ‘normal‘, recordsExpanded: me.recordsExpanded, rowBodyHiddenCls: me.rowBodyHiddenCls, rowCollapsedCls: me.rowCollapsedCls, setupRowData: me.getRowBodyFeatureData, setup: me.setup, getRowBodyContents: function(record) { return rowBodyTpl.applyTemplate(record.getData()); } },{ ftype: ‘rowwrap‘, lockableScope: ‘normal‘ }]; if (grid.features) { grid.features = Ext.Array.push(features, grid.features); } else { grid.features = features; } }
其实,就为了看看方法是否被覆盖了,在相同的位置加上了输出语句。代码执行之后,效果如下:
我是盖子。。 RowExpa...ride.js (第 6 行) oh my gd! ext-all-debug.js (第 117009 行)
居然没有被覆盖?!
本文出自 “技术人生” 博客,请务必保留此出处http://wangyuelucky.blog.51cto.com/1011508/1529704
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。