gpt4 book ai didi

javascript - 重新加载 Kendo UI 调度程序

转载 作者:行者123 更新时间:2023-11-28 06:25:20 24 4
gpt4 key购买 nike

你好,
我有两个不同的调度程序来一个接一个地显示。
在 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);
}
});

如何重新加载调度程序以更改 View ?
提前感谢您的回答,并为我的英语不好以及我的函数和评论的法语名称感到抱歉。

编辑:我见过一种“scheduler.view”方法,可以让我在两个 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();

}

但我的观点没有改变,有什么想法吗?

编辑2:我尝试用我上面描述的方法在“天”和“周”之间切换,并且它有效。新问题是:如何在两个 CustomView 之间切换?

最佳答案

我终于知道为什么它不起作用了。如果以后有人遇到同样的问题,我会发布答案。
我的调度程序声明中缺少一个参数。

<%=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.
})

希望有一天它能帮助别人!

关于javascript - 重新加载 Kendo UI 调度程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35174818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com