【问题标题】:Override Ext.Button OnRender event to enable/disable buttons覆盖 Ext.Button OnRender 事件以启用/禁用按钮
【发布时间】:2021-12-31 21:57:20
【问题描述】:

我试图在 ExtJS 3.4.0 中覆盖 onRender 事件,但这会产生脚本错误:对象不支持 callParent。我的目标是根据会话对象的权限启用或禁用按钮。

Ext.override(Ext.Button, {
            onRender: function () {
                this.callParent();

                console.log('do something');
            }
        });

【问题讨论】:

    标签: javascript extjs extjs3


    【解决方案1】:

    我已经用这几行代码解决了:

    Ext.onReady(function () {
    Ext.QuickTips.init();
    // get rights here
    
    if (roles.length > 0) {
        Ext.override(Ext.Button, {
            initComponent: function () {
                //filter rights here with matching text
                // if length is greater than 0, then enable disable buttons
                if (buttonRights.length > 0) {
                    if (this.text == buttonRoles[0].ItemText) {
                        this.setDisabled(!roles[0].IsAllowed);
                    }
                }
            }
        });
    }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-28
      • 2015-02-23
      • 1970-01-01
      • 2014-02-01
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 2023-01-23
      相关资源
      最近更新 更多