PDA

View Full Version : Overriding existing functionality safely



JamesC
17 Sep 2009, 1:59 AM
Am I correct in saying that doing the following is a safe (future-proof) way of overriding existing Ext components, for example - to add an afterrowrender to a gridview you can do the following:



Ext.override(Ext.grid.GridView, {
afterRender: Ext.grid.GridView.afterRender.prototype.createSequence(function() {
this.fireEvent("afterrowrender", this);
})
});


Is there anything wrong with this? It makes it much easier going forward when upgrading ext as I do not need to redo the whole override to the function.

Animal
17 Sep 2009, 2:04 AM
Well, that's not an after ROW render, that's an after WHOLE VIEW render. And in that particular case, there is already the new "viewready" event fired from the GridPanel (in the latest code) which tells you this.

But in general principle, yes, that's how to extend classes and add functionality to template methods.

JamesC
17 Sep 2009, 5:50 AM
Yes agreed - it's essentially on first load when the rows are ready - I'm glad viewready will be available in the future - is this in 3.1?