Kendo动态更新调度程序选项

时间:2014-08-14 18:10:54

标签: angularjs kendo-ui

我正在使用AngularJS的KendoUI调度程序。

我正在根据文档声明调度程序选项,非常标准的东西。见下文:

我想要做的是能够更新$scope.schedulerOptions并将这些更改反映在用户界面中。当我对$scope.schedulerOptions进行更改时,UI中没有任何更改。

关于如何做到这一点的任何想法?

$scope.schedulerOptions = {
        date: new Date("2013/6/13"),
        startTime: new Date("2013/6/13 07:00 AM"),
        height: 600,
        views: [
            "day",
            { type: "workWeek", selected: true },
            "week",
            "month",
        ],
        eventTemplate: "<span class='custom-event'>{{dataItem.title}}</span>",
        allDayEventTemplate: "<div class='custom-all-day-event'>{{dataItem.title}}</div>",
        timezone: "Etc/UTC",
        dataSource: {
            batch: true,
            transport: {
                read: {
                    url: "http://demos.telerik.com/kendo-ui/service/tasks",
                    dataType: "jsonp"
                },
                update: {
                    url: "http://demos.telerik.com/kendo-ui/service/tasks/update",
                    type: "PUT"
                },
                create: {
                    url: "http://demos.telerik.com/kendo-ui/service/tasks/create",
                    type: "POST"
                },
                destroy: {
                    url: "http://demos.telerik.com/kendo-ui/service/tasks/destroy",
                    type: "DELETE"
                },
                parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
            },
            schema: {
                model: {
                    id: "taskId",
                    fields: {
                        taskId: { from: "TaskID", type: "number" },
                        title: { from: "Title", defaultValue: "No title", validation: { required: true } },
                        start: { type: "date", from: "Start" },
                        end: { type: "date", from: "End" },
                        startTimezone: { from: "StartTimezone" },
                        endTimezone: { from: "EndTimezone" },
                        description: { from: "Description" },
                        recurrenceId: { from: "RecurrenceID" },
                        recurrenceRule: { from: "RecurrenceRule" },
                        recurrenceException: { from: "RecurrenceException" },
                        ownerId: { from: "OwnerID", defaultValue: 1 },
                        isAllDay: { type: "boolean", from: "IsAllDay" }
                    }
                }
            },
            filter: {
                logic: "or",
                filters: [
                    { field: "ownerId", operator: "eq", value: 1 },
                    { field: "ownerId", operator: "eq", value: 2 }
                ]
            }
        },
        resources: [
            {
                field: "ownerId",
                title: "Owner",
                dataSource: [
                    { text: "Alex", value: 1, color: "#f8a398" },
                    { text: "Bob", value: 2, color: "#51a0ed" },
                    { text: "Charlie", value: 3, color: "#56ca85" }
                ]
            }
        ]
    };

1 个答案:

答案 0 :(得分:3)

根据this post at telerik forum,您可以在初始化后将值更改为<div kendo-scheduler="sched" k-options="options"></div>并将访问的sched更改为模型变量$scope.sched.setOptions(...);