This is a migrated thread and some comments may be shown as answers.

Masked column in a grid

1 Answer 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avigayil
Top achievements
Rank 1
Avigayil asked on 07 Apr 2014, 05:56 PM
Hi.  I am a newbie to Kendo and Mvc in general. I am trying to add a column to a grid that I would like to display as masked (i.e.  a zip code with a "00000-0000" format, or a phone number with a (000)000-0000 format.

I have not found any examples for this.  Can someone please direct me to one?  The closest I see is a masked text box, but I don't see a  way to use this in a grid.


Thank you.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 09 Apr 2014, 09:04 AM
Hi Avigayil,

It is recommended to use column.template in order to format the data that is displayed in a Grid column. Kendo Template allows execution of JavaScript functions which gives ability to the developer to use kendo.toString or call another custom formatting function that will return the formatted string. For example:

{ field: "foo", template: "#= formatData(foo) #" }
 
//....
 
function formatData(value) {
   //format the value
   //return formatted value
}

In case you need to edit the value you can follow the approach demonstrated in custom editor demo to add masked text box editor.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Avigayil
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or