0

在 kendo ui 小部件代码触发后,我没有看到用于添加回调的文档。我有以下剑道 ui 小部件声明。

$("#scheduler").kendoScheduler({
    date: new Date("2013/6/13"),    // Change this to current date with twig
    startTime: new Date("2013/6/13 07:00 AM"), // Change this to 12:00 AM of current date
    allDaySlot: false,
    width:600,
    height:500,
    resize: function(e) {
        if (careGiverIsOccupied(e.start, e.end, e.event, e.resources)) {
            this.wrapper.find(".k-marquee-color").addClass("invalid-slot");
            e.preventDefault();
        }
    },
    resizeEnd: function(e) {
        if (!checkAvailability(e.start, e.end, e.events)) {
            e.preventDefault();
        }
    },
    move: function(e) {
        if (careGiverIsOccupied(e.start, e.end, e.event, e.resources)) {
            this.wrapper.find(".k-event-drag-hint").addClass("invalid-slot");
        }
    },
    moveEnd: function(e) {
        if (!checkAvailability(e.start, e.end, e.event, e.resources)) {
            e.preventDefault();
        }
    },
    add: function(e) {
        if (!checkAvailability(e.event.start, e.event.end, e.event)) {
            e.preventDefault();
        }
        changeColors();
    },
    save: function(e) {
        if (!checkAvailability(e.event.start, e.event.end, e.event)) {
            e.preventDefault();
        }
        changeColors();
    },
    views: [
        "week",
        "month"
    ],
    dataSource: {
        data: [
            {
                eventID: 2,
                title: "Hey man",
                start: new Date("2013/6/13 12:00"),
                end: new Date("2013/6/13 13:30"),
                pending: true,
                permissionToDelete: false,
                careGiverId: 1
            },
            {
                eventID: 1,
                title: "Call Charlie about the project",
                start: new Date("2013/6/13 10:30"),
                end: new Date("2013/6/13 11:30"),
                pending: false,
                permissionToDelete: false,
                careGiverId: 1
            }
            ],
        schema: {
            model: {
                id: "eventID",
                fields: {
                    eventID: { type: "number" },
                    title: { defaultValue: "No title", validation: { required: true } },
                    start: { type: "date" },
                    end: { type: "date" },
                    careGiverId: { nullable: true },
                    pending: { type: "boolean", defaultValue:true },
                    permissionToDelete: { type: "boolean", defaultValue:true },
                    isAllDay: { type: "boolean" }
                }
            }
        }
    },
    group: {
        resources: [ "care" ]
    },
    resources: [
        {
            field: "careGiverId",
            name: "care",
            dataSource: [
                { 
                    // Change the text with care giver name, change value with care giver id
                    text: "Jeffery Dohmer (Care Giver 1)", value: 1, color: "#00FF00" 
                }
            ],
            title: "Care"
        }
    ]
});

问题是我的文档的 dom 结构在 resizeEnd、move、moveEnd、add 和 save 等事件处理程序被触发后被修改。我想做的是在 kendoScheduler 添加或节省时间之后更改特定元素的颜色。完成后是否有添加回调?

4

2 回答 2

0

我为这个问题找到了一个优雅的答案。显然有一个名为 dataBound: 的事件允许在一切完成后触发回调。

就我而言,我想使用:

dataBound: function(e){

    // Code after widget is finished processing everything

}
于 2013-09-30T23:43:37.763 回答
0

看看这篇文章中的完整事件示例:

read: {
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: _op.serviceBaseUrl + "ReadX",
                complete: function () {
                      console.log('Tweak your UI here');
                 }
    }

显然,“完成”事件仅在您使用远程数据时可用。.

以及,看看这个requestEnd 事件

 requestEnd: function(e) {
    var response = e.response;
    var type = e.type;
    console.log(type); // displays "read"
    console.log(response.length); // displays "77"
  }

使用 switch one.type来区分不同的操作(请求的类型。设置为“create”、“read”、“update”或“destroy”。)

于 2013-09-29T19:38:04.183 回答