问题
I'm able to change the format of the dates for a kendo ui scheduler on the column headers using the dateHeaderTemplate property but I need to change the format of the date highlighted in the image below:
I'm sure there must be a pretty simple way of doing this but haven't found anything in the telerik docs so far.
回答1:
Please try with the below code snippet.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.common.min.css"/>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.rtl.min.css"/>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.silver.min.css"/>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.mobile.all.min.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.3.914/js/kendo.all.min.js"></script>
</head>
<body>
<div id="scheduler"></div>
<script>
$("#scheduler").kendoScheduler({
date: new Date("2013/6/6"),
views: [
"day",
{ type: "week", selected: true },
"month",
"agenda",
"timeline"
],
dataBound: scheduler_dataBound,
dataSource: [
{
id: 1,
start: new Date("2013/6/6 08:00 AM"),
end: new Date("2013/6/6 09:00 AM"),
title: "Interview"
}
]
});
function scheduler_dataBound(e) {
if (this.viewName() != "month") {
var test = $(".k-lg-date-format").html().split('-');
var _str = kendo.toString(kendo.parseDate(test[0].trim()), 'ddd MM/dd');
if (test.length == 2) {
_str += " - " + kendo.toString(kendo.parseDate(test[1].trim()), 'ddd MM/dd');
}
$(".k-lg-date-format").html(_str);
$(".k-sm-date-format").html(_str);
}
}
</script>
</body>
</html>
Let me know if any concern.
来源:https://stackoverflow.com/questions/39773490/kendo-ui-scheduler-change-date-format