I currently have a template that displays a date (among other things). When I was initially setting this up, I was told to use "#= kendo.toString(kendo.parseDate(data.CompletedDate), 'dd-MMM-yyyy') #" to display this date in the required format, which works perfectly.
Now I am attempting to move that date formatting into the datasource, in anticipation of future functionality. I found the dataSource -- schema -- parse functionality and thought it would work for what I wanted, but the formatting isn't actually working.
Here's a sample of the JSON being returned to the datasource:
When the template is displayed, the date is showing in mm/dd/yyyy format, not the specified dd-MMM-yyyy format. I copied the format string directly from the template code, so what's the problem?
9 Answers, 1 is accepted
Okay I understand what you're trying to do... you need to format the column not the data.
If I understood your question correctly, you want to re-format the date displayed using the schema parse function. In order to do so, you will need to first use the kendo.parseDate to parse the date and kendo.toString to produce a string in the appropriate format. The pasted code can be changed similar to the following:
Thanks for the reply, but I've tried that and it gives me the date in the mm/dd/yyyy format (which is the format being passed to the datasource).
You can see it happening here: http://app.smarteru.com/custom/kendo/index.cfm
Notice the difference between the tile and list views. Even though they share a datasource, the list view template is still doing kendo.toString(kendo.parseDate(data.Due), "dd-MMM-yyyy"); whereas the tile view just has #= data.Due # and it's not being formatted correctly.
The value of the field is not changed in this case, as the map is not applied on the correct object. The parse method receives the entire response, not only the data portion, thus in your scenario you will need to process the Courses field :