This is a migrated thread and some comments may be shown as answers.
Telerik Grid DateTime column not displaying 24 hour time format in Edit Mode
1 Answer 51 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gurpreet
Top achievements
Rank 1
Gurpreet asked on 28 Sep 2011, 07:37 PM

Hi

I am using telerik MVC Grid and facing issue with following line of code in Edit Mode :

columns.Bound(x => x.StartDateTime).Title(

 

"Start").HtmlAttributes(new { style = "text-align:center;width:250px" }).Format("{0:MM/dd/yyyy HH:mm}");

 

 

 

In Display Mode it displays Start column's time value in 24 hour format .  But in Edit mode Pop Up it displays Start column's time value in AM / PM format but I require it to display 24 hour format .

Can you please provide solution for the same ?

Thanks
Gurpreet

1 Answer, 1 is accepted

Sort by
0
Uchitha
Top achievements
Rank 1
answered on 29 Sep 2011, 04:28 AM
Hi Gurpreet,

The issue is to do with how telerik renders date time values in client side. Your 'Format' statement is valid only for Serverside and is used when rendering the date time for display (at server). But when you go to edit mode, the (time) popup/dropdowns are rendered in client side and telerik uses $.telerik.cultureInfo object to determine the relevant culture details (like date time patterns). 

There are several ways to fix this depending on how quick-clean-global you need the solution to be;

1. Make sure you set the proper pattern in $.telerik.cultureInfo class before you render the page. (In this case it should '$.telerik.cultureInfo.shortTime'). This will obviously impact only the page in question.

2. Make sure that the shortTimePattern of your CurrentCulture (@ serverSide) is set properly. You can use a (Global) Action Filter to implement this. This will impact the whole web application.

Tip : use a tool like Chrome Developer Tools to inspect client side telerik objects (like $.telerik). I find this a great method to learn how telerik does its magic at client.

Hope it helps.
Uchitha.
Tags
Grid
Asked by
Gurpreet
Top achievements
Rank 1
Answers by
Uchitha
Top achievements
Rank 1
Share this question
or