javascript – Kendo UI Web Scheduler – 动态修改资源dataSource
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – Kendo UI Web Scheduler – 动态修改资源dataSource,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2062字,纯文字阅读大概需要3分钟。
内容图文
![javascript – Kendo UI Web Scheduler – 动态修改资源dataSource](/upload/InfoBanner/zyjiaocheng/778/6a715f73f8a44898a6967dfdd863fe2f.jpg)
我正在尝试动态更改资源dataSource,但我正在进行的更改未应用于调度程序.
我已经创建了一个这样的调度程序:
$("#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
}
]
});
在修改了另一个控件之后,我尝试替换资源dataSource,将字段中值为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.setDatasource或resource.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 – 动态修改资源dataSource全部内容,希望文章能够帮你解决javascript – Kendo UI Web Scheduler – 动态修改资源dataSource所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。