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

How to get Grid and Form to send DateTime in the same format back to the server?

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaan
Top achievements
Rank 1
Kaan asked on 23 Jun 2016, 11:16 AM

Hi!

I have an editor template (DATETIMEEDIT.cshtml) for date times, which I use in a Grid and also in an ordinary form:

@model DateTime?
@(Html.Kendo().DateTimePickerFor(m => m)
.TimeFormat("HH:mm")
.HtmlAttributes(new { style = "width:100%;" })
)

 

The editor is bound to the Grid in this way:

var c = columns.Bound(fieldName);
c.EditorTemplateName("DATETIMEEDIT");
c.Format("{0:dd.MM.yyyy HH:mm}");

 

And this is how the editor is integrated into the HTML form:

@Html.EditorFor(v => dateTime, "DATETIMEEDIT", fieldName)

 

When I update the date and time, the Grid sends it back to the server as "3/21/2016 5:35:00 PM", and the form as "21.03.2016 17:35".

However, I need a reliable DateTime exchange format between the server and the client. "dd.MM.yyyy HH:mm" (24 hour) would be ok, but any other consistant solution would be alright too because if the server receives an unpredictable format, then I can't convert it into a C# DateTime object. Maybe there is another preferrable way to handle date times between the client and server? I don't even know why the Grid uses the American format as default because I work on a German workstation here.

 

Best,

Kaan

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 27 Jun 2016, 07:20 AM
Hi Kaan,


Please examine the following article that describes how you can have the same time format on the server and the client.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Kaan
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or