A thousands renderer for the Ext Grid control
Sep 17 2007
I needed to format large numbers by adding thousand separators in my Ext.js powered grid—and, as I couldn’t find one anywhere else, I wrote my own quick implementation. Here’s what I came up with:
function add_thousands_separator(input) {var s = input.toString(), l = s.length, o = '';while (l > 3) {var c = s.substr(l - 3, 3);o = ',' + c + o;s = s.replace(c, '');l -= 3;}o = s + o;return o;}- Download this code: /code/renderer.txt
Hopefully someone else might find this useful too.
Filed under: Javascript.
Technorati tags: javascript ext
Bookmark this article with del.icio.us
Previously: Refresh Cambridge 09/05 - Flex, Usability, and Drupal
Next: Porting Active Record to CodeIgniter