gpt4 book ai didi

javascript - Kendo UI Web Scheduler - 动态修改资源数据源

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:18:01 24 4
gpt4 key购买 nike

我正在尝试动态更改资源数据源,但我所做的更改并未应用于调度程序。

我创建了一个这样的调度程序:

$("#scheduler").kendoScheduler
({
date: new Date(),
startTime: new Date("2013/11/27 07:00 AM"),
endTime: new Date("2013/11/27 06:00 PM"),
height: "600",
selectable: true,
views: [
"day",
{ type: "workWeek", selected: true },
"week",
"month",
"agenda"
],

editable: {
template: kendo.template($("#schedulerTemplate").html())
},
dataSource: _dataSourceDetailedAppointmentScheduler,
edit: _api.onEditScheduler,
cancel: _api.onCancelScheduler,
save: _api.onSaveScheduler,

resources: [
{
field: "CommertialRepresentativeId", // The field of the scheduler event which contains the resource identifier
title: "Representante Comercial", // The label displayed in the scheduler edit form for this resource
dataSource: [
{
text: "Representante 1", // Text of the resource instance
value: 1, // Identifier of the resource instance, use that value to assign an event to this instance.
color: "#ff0000" // Used as the background of events assigned to this resource.
},
],
multiple: false // Indicate the this is a multiple instance resource
}
]

});

在修改另一个控件后,我尝试替换资源数据源,将字段中值为 1 的事件的颜色更改为绿色:“CommertialRepresentativeId”。

_dataSourceDetailedAppointmentScheduler.read();
var schedulerControl = $("#scheduler").data("kendoScheduler");
//Construir
var resourceDS = new kendo.data.DataSource(
{
data: [
{ text: "rep 1",
value: 1,
color: "#00ff00"
}
]
}

);
resourceDS.read();

schedulerControl.resources[0].dataSource = resourceDS;
schedulerControl.view(schedulerControl.view().name);

似乎无法弄清楚为什么调度程序会继续以原始颜色显示事件。

非常感谢您的帮助!

最佳答案

你应该使用 resource.setDatasourceresource.dataSource.data()更新配置:

var data = [{ text: "rep 1", value: 1, color: "#00ff00" }];
schedulerControl.resources[0].dataSource.data(data);

如果您不想替换所有数据而只想更改一项,这也应该有效:

// id if you have one, otherwise dataSource.at(index) if you know the index
var existingItem = schedulerControl.resources[0].dataSource.get(id);
existingItem.set("color", "#00ff00");

关于javascript - Kendo UI Web Scheduler - 动态修改资源数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20669451/

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