---
title: "How to format telephone number in Telrik MVC Grid Client.Template?"  
description: "How to format telephone number in Telrik MVC Grid Client.Template?"  
author: "Pravesh Singh"  
published: 2014-11-20  
updated: 2014-11-20  
canonical: https://www.mindstick.com/forum/12648/how-to-format-telephone-number-in-telrik-mvc-grid-client-template  
category: ".net"  
tags: ["telerik grid", "telerik mvc", "string"]  
reading_time: 1 minute  

---

# How to format telephone number in Telrik MVC Grid Client.Template?

How can i format Telephone number from xxxxxxxxxx to (xxx) xxx-xxxx

in telerik [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) [Grid](https://www.mindstick.com/forum/369/how-can-i-add-a-column-name-to-my-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](https://www.mindstick.com/forum/1763/string-format-with-null-values-c-sharp)("{0:###-###-####}", "<#= Telephone #>") + "<br />" + Regex.Replace("<#= Fax #>", formatPattern, "($1) $2-$3")).ToString()).Title("[Phone](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) / Fax");

I tried both ways String.format and Regex.Replace

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

but no use.

## Replies

### Reply by Samuel Fernandes

I got this done with the below code.

In Telerik Grid bound the column like this

.ClientTemplate("<#= GetPhoneFaxTemplate(data) #>").Title("Phone / Fax");

And the Scripts goes like this

```
function GetPhoneFaxTemplate(data) {        if(isNumeric(data.Telephone)) {            var phone= $.telerik.formatString('{0:(###) ###-####}', Number(data.Telephone))        }        else {            phone =data.Telephone;        }        if
(isNumeric(data.Fax)) {            var fax =$.telerik.formatString('{0:(###) ###-####}', Number(data.Fax))        }        else {            fax =data.Fax;        }        template =phone + "<br />" + fax;        return template;    }    function
isNumeric(n) {        return !isNaN(parseFloat(n)) && isFinite(n);    }
```


---

Original Source: https://www.mindstick.com/forum/12648/how-to-format-telephone-number-in-telrik-mvc-grid-client-template

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
