首页 > 代码库 > 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