PDA

View Full Version : How to format phone number in grid column in ext



eaglefox12
13 Dec 2012, 6:48 AM
I am trying to format phone number on a grid column from 1234567890 to 123-456-7890. I tried something of this sort to do...


renderer: Ext.util.Format.dateRenderer('Y-m-d') but obviously this only works for date. Is there a way to render phone numbers?

skirtle
13 Dec 2012, 8:11 AM
Lots of ways to do it... Here's one:


renderer: function(value) {
return value.replace(/^(\d{3})(\d{3})(\d{4})$/, '$1-$2-$3');
}

eaglefox12
13 Dec 2012, 11:08 AM
Lots of ways to do it... Here's one:


renderer: function(value) {
return value.replace(/^(\d{3})(\d{3})(\d{4})$/, '$1-$2-$3');
}
Thank you skirtle... much appreciated