我的页面上有一个剑道调度程序。
<div kendo-scheduler k-options="schedulerOptions" k-data-source="items"></div>
我的角度控制器将调用服务器以获取数据,它看起来像这样,但我不知道我的 URL 参数将是什么,直到它加载($scope.$watch)。
$scope.$watch(function () { return MyService.leadID; }, function (newValue) {
if (newValue) {
getAppointmentsTabData(newValue);
}
});
var getAppointmentsTabData = function (leadID) {
MyService.getAppointmentsTabData(leadID)
.then(function (data) {
$scope.items = data;
}
}
);
};
如何将此数据绑定到我的 Kendo 调度程序?
我可以让这个调度程序处理静态数据,但不能处理服务器发送它们时返回的对象的 JSON 列表。我希望能够将我的 $scope.items 绑定到数据源,但这似乎不起作用。
这是 schedulerOptions 代码。
$scope.schedulerOptions = {
date: new Date("2014/10/13"),
startTime: new Date("2014/10/13 07:00 AM"),
height: 310,
views: [
"agenda",
{ type: "week", selected: true, allDaySlot: false },
{ selectedDateFormat: "{0:dd-MM-yyyy}" }
],
eventTemplate: "<span class='custom-event'>{{dataItem.title}}</span>",
allDayEventTemplate: "<div class='custom-all-day-event'>{{dataItem.title}}</div>",
timezone: "Etc/UTC",
dataSource: {
data: $scope.items,
schema: {
model: {
id: "id",
fields: {
id: { from: "ID", type: "number" },
appointmentId: { from: "AppointmentId", type: "number" },
resource: { from: "Resource", type: "number" },
description: { from: "Description" },
isAllDay: { type: "boolean", from: "IsAllDay" },
end: { from: "End", type: "date" },
start: { from: "Start", type: "date" },
title: { from: "Title", defaultValue: "No title" },
startTimezone: { from: "StartTimezone" },
endTimezone: { from: "EndTimezone" },
recurrenceRule: { from: "RecurrenceRule" },
recurrenceException: { from: "RecurrenceException" },
}
}
},
}
};
我可以使用静态方法。我不能真正使用看起来像这样(下)的远程数据方法,因为在触发 $scope.$watch 之前我不知道我的 URL 是什么。我需要附加查询字符串参数。
dataSource: {
batch: true,
transport: {
read: {
url: "/MyController/GetMyData",
dataType: "json",
},
有人对我如何动态填充我的调度程序数据源有任何建议吗?
我已经看到了这个问题,Kendo update scheduler options dynamic,但我没有任何运气获得 setOptions()。如果我可以调用 $scope.myScheduler.setOptions("dataSource", myJsonObjectArry),那就太棒了,但没什么。
我能够操作 $scope.myScheduler._data (作为一个数组),但我需要某种形式的刷新方法来重绘我的 UI。不过,这种方法似乎并不正确。
谢谢你的帮助。