Brett
Brett

Reputation: 2746

Extjs overrides - loading required file before override

I am trying to apply a patch using overrides, but I am getting "Uncaught TypeError: Cannot read property 'Table' of undefined " because the Ext.view.Table file has not finished loading by the time the script gets called. How do I make sure the required files gets loaded before this is called?

Ext.define('CSnet.overrides.Table', {
  override: 'Ext.view.Table',
  getRowStyleTableElOriginal: Ext.view.Table.prototype.getRowStyleTableEl,
  getRowStyleTableEl: function() {
    var el = this.getRowStyleTableElOriginal.apply(this, arguments);

    if (!el) {
      el = {
        addCls: Ext.emptyFn,
        removeCls: Ext.emptyFn,
        tagName: {}
      }
    }

    return el;
  }
});

Upvotes: 1

Views: 787

Answers (1)

Christoph
Christoph

Reputation: 1023

You can define a class which handles all your overrides, e.g.

Ext.define('YourApp.Overrider',{
    requires: ['TargetClass'],
    doOverride: function() {
        Ext.define('CSnet.overrides.Table', {
        override: 'Ext.view.Table',
        // snip
        });
    }
});

You can requires this class in your app.js and call doOverride in app.launch(), after the framework has been loaded. Additionally, you can require the specific TargetClass that you want to override in the require-config of the Overrider.

Upvotes: 1

Related Questions