Override Ext.Button OnRender event to enable/disable buttons

96 views Asked by At

I am trying to override onRender event in ExtJS 3.4.0 but this gives a script error: object does not support callParent. My objective is to enable or disable buttons based on the rights from session object.

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

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

There are 1 answers

0
Salman Rafique On

I have resolved with these lines of code:

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);
                }
            }
        }
    });
}
});