This question is locked. New answers and comments are not allowed.
Can Any one help me how can i Format Telephone Number in Telerik MVC Grid.
this is my code
Above Code it Not working.
Any help would be greatly appreciated.
Thanks
this is my code
columns.Bound(e=>e.ID).ClientTemplate("<#= $.telerik.formatString('{0:###-###-###}',Telephone) #> <br /> <#= $.telerik.formatString('{0:###-###-###}',Fax) #> ").Title("Phone / Fax");Above Code it Not working.
Any help would be greatly appreciated.
Thanks
4 Answers, 1 is accepted
0
Hello Harsha,
To use the "#" character in a Template you should declare a JavaScript function which applies the formatting and call it from the template. For example:
Kind regards,
Daniel
the Telerik team
To use the "#" character in a Template you should declare a JavaScript function which applies the formatting and call it from the template. For example:
columns.Bound(e=>e.ID) .ClientTemplate("<#= GetPhoneFaxTemplate(data) #>").Title("Phone / Fax"); <script type="text/javascript">function GetPhoneFaxTemplate(data){ var template = $.telerik.formatString('{0:###-###-###}',data.Telephone) + "<br/>" + $.telerik.formatString('{0:###-###-###}',data.Fax) return template;}</script>Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
HaBo
Top achievements
Rank 1
answered on 06 Dec 2011, 08:19 PM
No use. with the Function
alert gives me ########## <br /> ##########
it is not formatting as declared in statement
function GetPhoneFaxTemplate(data) { var template = $.telerik.formatString('{0:###-###-####}', data.Telephone) + "<br/>" + $.telerik.formatString('{0:###-###-####}', data.Fax) alert(template); return template; }it is not formatting as declared in statement
$.telerik.formatString('{0:###-###-####}', data.Telephone)0
Hi Harsha,
Daniel
the Telerik team
The $.telerik.formatString method accepts number as parameter. So if the Telephone and Fax fields
are Strings it will not work as expected.
I attached a project which demonstrates how to use the Template in such cases. I hope it helps.
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
HaBo
Top achievements
Rank 1
answered on 09 Dec 2011, 03:33 PM
Thank you very much it helped me a lot