I want to build a Kendo UI Grid with format date dd//MM/yyyy. However, all questions that I found about this, it were resolved with code Format(\"{0:d}\");. So,
The core issue is documented really well here. Combining the answers there with other stuff I found, here's what I had to do to get it to work on my project.
In the C# code:
.Template("#= kendo.toString(parseDate(" + field.Name + "), 'dd/MM/yyyy') #");
Then, create a javascript function:
function parseDate(d) {
d = new Date(parseInt(d.replace(/\/Date\((-?\d+)\)\//gi, "$1"), 10));
return d;
}
It's a bit of a kluge, but works.
Thanks for your answers:
I format a duration in seconds in HH:MM:SS in a Kendo grid column using a ClientTemplate and calling a javascript function:
.ClientTemplate("#= secToHHMMSS(DurationInSeconds) # ")
.Title("Duration")
.Width(150);
function secToHHMMSS(s) {
f = Math.floor;
g = (n) => ('00' + n).slice(-2);
return f(s / 3600) + ':' + g(f(s / 60) % 60) + ':' + g(s % 60)
}