您好,
我有两个不同的调度程序一个接一个地显示。
在js文件中我有这个功能:
function doRafraichirInterface() {
if (b_FENETRE_OUVERTE) {
return;
}
if (flag == false){
flag = true;
console.log(flag);
}
else{
flag = false;
console.log(flag);
}
// Rafraichissement du planning
$("#scheduler").data("kendoScheduler").dataSource.read();
$("#scheduler").data("kendoScheduler").refresh();
}
此功能每15秒调用一次。
在.aspx文件中,我使用了Kendo UI Schedule:
var myView = kendo.ui.MultiDayView.extend({
options: {
selectedDateFormat: "{0:D} - {1:D}"
},
name: "Un jour",
calculateDateRange: function() {
//create a range of dates to be shown within the view
var ladate = new Date();
var Today = ladate.getDay();
var year = ladate.getFullYear();
var month = ladate.getMonth();
var day = ladate.getDate();
var selectedDate = this.options.date,
idx, length,
dates = [];
if (flag == false)
dates.push(new Date(year, month, day));
else{
if (Today == 1)
{
var start = kendo.date.dayOfWeek(selectedDate, Today - 2, -1);
}
else
{
var start = kendo.date.dayOfWeek(selectedDate, Today - 1, -1);
}
for (idx = 0, length = 8; idx < length; idx++) {
if (start.getDay() != 0) {
dates.push(start);
}
start = kendo.date.nextDay(start);
}
}
this._render(dates);
}
});
如何重新加载调度程序以更改视图?
感谢您提前回答您的问题,并对我的错误英语和我的职能和评论的法语名称表示歉意。
编辑:我见过一个“scheduler.view”方法,可以让我在两个视图之间切换。所以我把我的两个函数拆分成这样:
var oneDayView = kendo.ui.MultiDayView.extend({
options: {
selectedDateFormat: "{0:D} - {1:D}"
},
name: "Un jour",
calculateDateRange: function() {
//create a range of dates to be shown within the view
var ladate = new Date();
var year = ladate.getFullYear();
var month = ladate.getMonth();
var day = ladate.getDate();
var selectedDate = this.options.date,
idx, length,
dates = [];
dates.push(new Date(year, month, day));
this._render(dates);
}
});
var oneWeekView = kendo.ui.MultiDayView.extend({
options: {
selectedDateFormat: "{0:D} - {1:D}"
},
name: "Une semaine",
calculateDateRange: function() {
//create a range of dates to be shown within the view
var ladate = new Date();
var Today = ladate.getDay();
var selectedDate = this.options.date,
idx, length,
dates = [];
if (Today == 1)
{
var start = kendo.date.dayOfWeek(selectedDate, Today - 2, -1);
}
else
{
var start = kendo.date.dayOfWeek(selectedDate, Today - 1, -1);
}
for (idx = 0, length = 8; idx < length; idx++) {
if (start.getDay() != 0) {
dates.push(start);
}
start = kendo.date.nextDay(start);
}
this._render(dates);
}
});
并将“doRafraichirInterface”更改为:
function doRafraichirInterface() {
if (b_FENETRE_OUVERTE) {
return;
}
if (flag == true){
console.log(flag);
flag=false;
$("#scheduler").data("kendoScheduler").view("oneDayView");
}
else{
console.log(flag);
flag=true;
$("#scheduler").data("kendoScheduler").view("oneWeekView");
}
// Rafraichissement du planning
$("#scheduler").data("kendoScheduler").dataSource.read();
$("#scheduler").data("kendoScheduler").refresh();
}
但是我的观点没有改变,有什么想法吗?来自EDIT2:我尝试用我描述得更高的方法在“日”和“周”之间切换,并且它正在工作。新问题是:如何在两个CustomView之间切换?
答案 0 :(得分:0)
我终于找到了为什么它不起作用。如果以后有人遇到同样的问题,我会发布答案
我的调度程序声明中缺少一个参数。
<%=Html.Kendo()
.Scheduler<IntranetMVC.Models.Planification>()
.Name("scheduler")
.Date(DateTime.Now)
.Height(737)
.AllDaySlot(false)
.StartTime(new DateTime(2000, 1, 1, 0, 0, 0))
.EndTime(new DateTime(2099, 12, 31, 23, 55, 55))
.ShowWorkHours(true)
.WorkDayStart(new DateTime(2000,1, 1, 7, 0, 0))
.WorkDayEnd(new DateTime(2099,12, 31, 18, 0, 0))
// Configuration des vues disponibles
.Views(views=>
{
views.CustomView("oneDayView");//Don't forget to put every
views.CustomView("oneWeekView");// views that you need to switch to.
})
希望有一天能帮助别人!