首页 > extjs defer 传值问题

extjs defer 传值问题

我是在做 gridcolumn 按钮遇到这个问题的。

首先我试了两种方式,一种是 :xtype : 'actioncolumn', (这种没有按钮的样子,没有按钮的样式,不符合需求)

这个我简单做了一个,大概这样:


另一种是 renderer 加全局Id 。混在一起写,是完全没有问题,但是后面需求解藕 ,必须拆出来。但是我在模块化时,一直传不进去全局id的值。你们能给点建议么?
我参考的这个链接:Add button to Extjs GridPanel cell using renderer

        ......
        columns: [{
                text: '任务编号',
                dataIndex: 'taskId',
                flex: 1
            }, {
                text: '申请人',
                dataIndex: 'applyUser',
                flex: 1
            }, {
                text: '审批人',
                dataIndex: 'assignee',
                flex: 1
            }, {
                text: '操作',
                align: 'center',
                renderer: this.operate,
                flex: 1
            }
        ]
    });
},

operate: function (value, meta, rec) {
    var id = Ext.id();
    this.createGridButton.defer(1, this, ['办理',  meta, rec, id]);
    return Ext.String.format('<div id="{0}"></div>', id);
},

createGridButton : function(){
    Ext.widget('button', {
        renderTo: id,
        text: '办理',
        scale: 'small',
        handler: function() {
            console.log("内部调用");
        }
    });
}

第一次修改

我在 operate 的创建id后,加了两个输出语句:

    console.log(this.createGridButton);
    console.log(this.createGridButton.defer());

只执行了第一个,没有执行第二个,这是说,Extjs 5 必须 用Ext.defer() 或者 Ext.Function.defer 来调么?


是的,你需要使用 Ext.defer(fn, args...) 来调用这个方法,ExtJS 并没有污染 Function 的原型。

【热门文章】
【热门文章】