DateTime field losing milliseconds in Kendo Grid Update Action

3 posts, 0 answers
  1. Zhang
    Zhang avatar
    2 posts
    Member since:
    Nov 2017

    Posted 28 Nov 2017 Link to this post

    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. Stefan
    Admin
    Stefan avatar
    2880 posts

    Posted 29 Nov 2017 Link to this post

    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.
  3. Zhang
    Zhang avatar
    2 posts
    Member since:
    Nov 2017

    Posted 29 Nov 2017 Link to this post

    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.

Back to Top