JavaScript and ExtJs function to mask a numberfield.

This simple function adds a well format to a field in extjs, use it in a render on a column grid.


function format(value) {
var decimalplaces = 3; // or any other number
var pad = '0';
if(decimalplaces > 0) {
pad += '.';
for(var i = 0; i < decimalplaces; i++) {
pad += '0';
}
}
return Ext.util.Format.number(value, pad);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s