Formatted Number Column in EXT-JS Grid

The standard display of a number in a grid panel contains no delimiters or decimals. If you want to add one, you can apply a renderer to the column.
[code language=”javascript”]
{
header : ‘Total Population’,
dataIndex : ‘population’,
width:70,
renderer : function() {
return Ext.util.Format.numberRenderer(‘0,000’);
}
}
[/code]

I prefer to externalize this to a separate location, in this case a Utility class.
[code language=”javascript”]
// in Util:
Util = {
thousandsRenderer : function() {
return Ext.util.Format.numberRenderer(‘0,000’);
}
}

// For grid
{
header : ‘Total Population’,
dataIndex : ‘population’,
width:70,
renderer : Util.thousandsRenderer()
},
[/code]

Enjoy!