I'm binding a Kendo UI date widget to a property within an object (TestDate in my example below).
TestDate is populated with json returned from a web service - in below example, goalHeader1 is the object populated from json. The problem is that json specifies the date in an ISO std string. Kendo grid columns handle this well, but form controls only seem to handle pure JavaScript date values. Of course I could add code to transform each json date into a javascript date on the client, but I don't want to ask all our app devs to do that each time they call a web service.
We're using MVC webapi v1 to transform our objects into json. Thoughts?
http://jsfiddle.net/gQcS3/8/
Code:
var observable = new kendo.data.ObservableObject({
goalHeader1: {
TestDate: "2014-01-02T00:00:00",
test: "testText"
}
});
// following statement generated from Kendo's asp.net wrapper Q3 2013:
jQuery(function(){jQuery("#testDate").kendoDatePicker({"format":"M/d/yyyy","min":new Date(1900,0,1,0,0,0,0),"max":new Date(2099,11,31,0,0,0,0)});});
kendo.bind($(document.body), observable);
Use parseFormats when you create your date picker:
See demo.