-
-
Save anonymous/4290ea9cf20de7efe267 to your computer and use it in GitHub Desktop.
Using a custom renderer function in ExtJS4 to properly handle currency rounding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Uses https://github.com/MikeMcl/big.js/ | |
to allow for arbitrary decimal precision and | |
get away from floating point inaccuracy | |
*/ | |
{ | |
xtype : 'numbercolumn', | |
header : 'Price', | |
dataIndex : 'line_item_price', | |
renderer : function( v ) { | |
return '$' + Big( v ).toFixed(2); | |
} | |
} | |
// The example number is 20.775 | |
// Calling this renderer with v = 20.775 | |
// returns "$20.78" as expected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment