PDA

View Full Version : Overriding Ext.util.Format.usMoney....



rbastic
14 Oct 2010, 6:49 AM
Hello, I was wondering how I could override/extend Ext.util.Format.usMoney. The typical approach using Ext.util.Format.prototype does not work.

The reason I need to do this is because the usMoney formatter does not properly handle null/undefined values.


if (Ext.isEmpty(v)) {
return '$0.00';
}


Adding that to the top of the function in ext-all-debug.js is the only way I've been able to fix this.

Any advice? I don't want to have to maintain my own changes to ExtJS.

-Ryan

Animal
14 Oct 2010, 6:59 AM
Ext.util.Format is a singleton object which just contains methods. There's no prototype or constructor. It's just there.

VinylFox
14 Oct 2010, 7:40 AM
You might want to check out my Blog Post on Overriding (http://www.vinylfox.com/patterns-using-ext-js-override/), the same concepts will apply, though as Animal noted, Format is a singleton so the syntax will be different.

rbastic
14 Oct 2010, 8:54 AM
Of me getting my fix included in the next version of ExtJS?

If you've looked at the source for the 'Format' function, an override is definitely not the best way to affect it... am I right? Or is there something glaringly obvious that I'm missing?

VinylFox
14 Oct 2010, 9:26 AM
If you file a bug report in the Bugs forum with all the required information, the odds are great.

rbastic
14 Oct 2010, 9:27 AM
Didn't include all the required information, but it should be working the same way regardless of browser/OS used.... So hopefully it makes it's way in. :)