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

JSON dates and view models

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 08 May 2013, 04:42 PM
In order to flatten my data and avoid circular references, I created a view model for an object generated by OpenAccess ORM. I noticed something interesting, though. When binding the grid to my new view model (Html.Kendo().Grid<ViewModel>()...), my DateTime fields get converted into JSON dates when the grid is rendered (e.g. /Date(1362974400000)/). However, when I bind the grid to the original model (Html.Kendo().Grid<OpenAccessModel>()...), the dates come out as expected (e.g. Mon Mar 11 2013 00:00:00 GMT-0400 (Eastern Daylight Time)).

I've manipulated the code so that I've isolated the binding as the only difference. There's something different about the two classes that is causing a difference in rendering of the date field (even though that field is a DateTime field for both classes). Any idea why this is happening and if there's a simple way to fix this? Perhaps a bit of metadata attached to the field through OpenAccess that I should include in the view model?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 May 2013, 08:48 AM
Hello Jacob,

I am not sure what is causing the problem. Could you provide the code you are using so I can check the setup? For now I can say that the JSON date will not be converted to a JavaScript if the dataSource does not know the field type. This could happen if the date field is in a complex property because the schema supports only a single level. 

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or