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

Grid ClientTemplate for all Types

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 2
Veteran
Kyle asked on 31 Mar 2014, 07:59 PM
I'm trying to use a ClientTemplate for all of my columns to allow an HTML hover tooltip (using span's title attribute).  My ClientTemplate currently is:

string.Format("<span title='#: {0} #'># if ({0} != null) {{# #= {0} # #}}#</span>", fieldName)


This works wonderfully for strings.  However, for enums or DateTime, numbers, etc, it doesn't obey the DataAnnotations.  It simply does a raw output.  How does the Kendo MVC Grid know how to display these fields (without a ClientTemplate, it's perfect without a tooltip)?  How can I slightly tweak my ClientTemplate so that it works for all columns/types?

Thanks in advance,
Kyle

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Apr 2014, 03:37 PM
Hi Kyle,

When displaying its data, the Grid takes into consideration the column field types and defined formats, if set. The information is used to convert non-string objects (dates, numbers) to strings. In your case this must be done manually in the client template code, since the data field types are known. You can use kendo.toString() and kendo.format() if you find them helpful.

http://docs.telerik.com/kendo-ui/api/framework/kendo

Regards,
Dimo
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
Kyle
Top achievements
Rank 2
Veteran
Answers by
Dimo
Telerik team
Share this question
or