PDA

View Full Version : Ux.util.Format.addCommas



SpNg
24 Jan 2011, 11:43 AM
I saw this was not in Touch right now, but is pretty helpful. It's a quick function for adding commas to numbers in templates. You use it in a template just like other formatting options i.e. {number:addCommas}

Enjoy.



Ext.util.Format.addCommas = function (str) {
   str = str.split('.');
   while(str[0] != (str[0] = str[0].replace(/(\d+)(\d{3})/, '$1,$2')));
   return str.join('.');
}

mitchellsimoens
24 Jan 2011, 1:41 PM
This should be posted in the Feature Request forum if you want it added to the framework.