forum

home / developersection / forums / how to format telephone number in telrik mvc grid client.template?

How to format telephone number in Telrik MVC Grid Client.Template?

Pravesh Singh 3150 20-Nov-2014

How can i format Telephone number from xxxxxxxxxx to (xxx) xxx-xxxx

in telerik MVC Grid .client.template.

I tried something like this. which is not working

string formatPattern = @"(\d{3})(\d{3})(\d{4})";

 columns.Bound(e=>e.ID)

 .ClientTemplate(Html.Raw(String.Format("{0:###-###-####}", "<#= Telephone #>") + "<br />"      + Regex.Replace("<#= Fax #>", formatPattern, "($1) $2-$3")).ToString()).Title("Phone / Fax");

I tried both ways String.format and Regex.Replace

I also tried $.telerik.formatString('{0:###-###-####}'<#= telephone =>)

but no use.


Updated on 20-Nov-2014
Can you answer this question?

Answer

1 Answers

Liked By