【问题标题】:How to render icon and call function when click icon单击图标时如何渲染图标和调用函数
【发布时间】:2015-02-10 04:19:31
【问题描述】:

我想使用渲染器来做锁定/解锁图标按钮。如果单击该按钮,它将显示消息框是/否以确认。如果单击是,它应该调用 SubmitValue 函数。问题是它不能调用javascript SubmitValue 函数。单击是确认框时如何调用函数?

渲染器.js

var renderLock = function (value, p, record) {
    if (JSON.parse(value))
    {
        return '<img src="Images/icon/lock.png" >';
    }
    else 
    {
        return '<img src="Images/icon/unlock.png" >';
    }
}

Common.js

var GetGrid_LockButton = function (Active, FieldId, FieldName, Grid_Name, URL) {
return {
    menuDisabled: true
    , sortable: false
    , hidden: Permit_No_Del
    , text: 'Lock'
    , renderer: renderLock
    , align: 'center'
    , xtype: 'actioncolumn'
    , dataIndex: 'IS_LOCK'
    , width: 45
    , listeners: {
        click: function () {
            Ext.MessageBox.confirm('confirm?', function (btn) {
                if (btn == "yes") {      
                    SubmitValue(URL, { id: rec.get(FieldId) }, "Ext.getCmp('" + Grid_Name + "').getStore().load();", "Yes");
                }
            });

        }
    }
   };
}

提前谢谢你。

【问题讨论】:

    标签: javascript extjs


    【解决方案1】:

    我认为您可能在范围方面存在问题,请注意在下面您的确认调用的修改版本中添加为最后一个参数的“this”关键字

    Ext.MessageBox.confirm('confirm?', function (btn) {
        if (btn == "yes") {      
            SubmitValue(URL, { id: rec.get(FieldId) }, "Ext.getCmp('" + Grid_Name + "').getStore().load();", "Yes");
        }
    },this);
    

    默认情况下,confirm 调用中的范围默认为浏览器窗口对象,因此我想在该级别您的 SubmitValue 函数不可访问。

    【讨论】:

      猜你喜欢
      • 2018-06-09
      • 2015-07-02
      • 2021-12-21
      • 2019-03-02
      • 2020-07-23
      • 2021-08-24
      • 1970-01-01
      • 2016-11-13
      • 2017-02-27
      相关资源
      最近更新 更多