我試圖動態地更改資源數據源,但我所做的更改未應用於調度程序。Kendo UI Web調度程序 - 動態修改資源數據源
我創建了一個調度程序,如下所示:
$("#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);
似乎無法弄清楚爲什麼調度器將繼續以原始顏色顯示事件。
我會感謝一些幫助!
我結束了除去最初包括後這樣做元素:'schedulerControl.resources [0] .dataSource.add({text:「Rep 1」,value:1,color:「#00ff00」});'是否等價? –
@ gaguevaras如果你只想改變一個項目,那會工作;如果您只想對項目進行小改動,我還編輯了另一個想法的答案 –