Best way to override updater globally?

  • I have created my own renderer for updaters. I need to make it so that ALL Ext.Panel instances use this new Updater.Renderer instead of the default Updater.BasicRenderer.

    I know how to tell individual panels to do it, via the getUpdater()->setRenderer() method, but what about globally for ALL panels that could be instantiated?

    I could just use JS to directly override the Updater prototype's getRenderer() method, but it seems like there is probably a more Ext-friendly approach.

    I appreciate all feedback :)


  • Renamed DefaultRenderer to defaultRenderer.


  • Thanks for the heads up. I was including the file after and developing on a 2nd copy of UpdateManager.js and therefore BasicRenderer already existed. d'oh!

    Anyways added it and put in some documentation.

    @y0y - You would override your own custom renderer like this:

    Ext.Updater.override({
    getDefaultRenderer: function() {
    return MyCustomRenderer;
    }
    });


  • y0y -

    As of Ext 2.1 there is no easy way to do this because Ext instantiates an instance of Ext.Updater.BasicRenderer in its constructor.

    Like this:

    this.renderer = new Ext.Updater.BasicRenderer();


    I've moved created a new property on the prototype of Ext.Updater called DefaultRenderer and defaulted it to the BasicRenderer.

    This way in current SVN (and in the next release) you could override the default renderer for all Updaters like so:

    Ext.Updater.prototype.DefaultRenderer = MyCustomRender;


  • the new defaultRenderer config causes a script error because Ext.Updater.BasicRenderer is undefined when Ext.Updater is being parsed by the js engine.

    might be better to change it to

    if(!this.renderer){
    this.renderer = this.getDefaultRenderer();
    }


    and

    getDefaultRenderer: function() {
    return new Ext.Updater.BasicRenderer();
    }


  • Awesome guys. Thank you so much for the fast response and decisive action!

    ..now if the procurement department would just hurry up and get me that ExtJS subscription so I can get SVN access... ;)