This is a migrated thread and some comments may be shown as answers.
DateTime field losing milliseconds in Kendo Grid Update Action
2 Answers 29 Views
This is a migrated thread and some comments may be shown as answers.
Zhang
Top achievements
Rank 1
Zhang asked on 28 Nov 2017, 06:06 AM

I have a kendo grid with inline editing enabled. One of the field is a datetime field and it is configured to be non-editable. After a update(or delete) action is triggered, the millisecond part of the value of the field is lost in the controller. Is there anyway to avoid it?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 29 Nov 2017, 12:25 PM
Hello, Zhang,

In general, the milliseconds part should be sent to the Controller as well.

In some cases due to C# specifics, the milliseconds part may seem as lost:

https://stackoverflow.com/questions/26907812/datetime-losing-milliseconds

https://stackoverflow.com/questions/23788656/datetime-parseexact-omitting-milliseconds-in-c

Also, please ensure that the format of the DateTimePicker used as editor is set with milliseconds as well.

If the issue still occurs, please provide a fully runnable example and I will gladly assist.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Zhang
Top achievements
Rank 1
answered on 30 Nov 2017, 01:37 AM

I have found the root cause. But thanks for the reply anyway.

The millisecond part is lost at the client side (View), not at the server side (Controller). DateTimePicker is not used at all.

When a update/delete command is triggered at the view, the script at kendo.aspnetmvc.min.js will try to serialize the object for posting the data back to the server. The javascript code uses the 'G' format to convert the datetime field to a string and this causes the loss of the millisecond part. Changing the parser in the script to use "toISOString()" instead of "kendo.toString(value, 'G', this.culture.name)" resolves the issue.

Tags
Grid
Asked by
Zhang
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Zhang
Top achievements
Rank 1
Share this question
or