Kendo UI Scheduler TimeZone问题

时间:2016-10-28 06:57:21

标签: datetime kendo-ui kendo-scheduler

在创建新事件时,数据将从db中正确存储和获取。但是,kendo ui调度程序没有正确显示。例如,我为" 2016-10-31 09:00:00.000"创建了一个活动,该活动显示在" 2016-10-30 10:00 PM"的UI上。我验证了该服务返回的值,它来自1477864800000,并且在控制台上它被打印为" Mon Oct 31 2016 09:00:00 GMT + 1100(AUS Eastern Daylight Time)"

请提供建议,我需要提及时区:" Etc / UTC" ,或者我的JS代码可能出错。

            $(function () {
                    $("#scheduler").kendoScheduler({
                        date: new Date(),            
                        height: 600,
                        views: [
                          "day",
                          { type: "week", selected: true },
                          "month"
                        ],
                        editable: {
                            template: $("#customEditorTemplate").html(),
                        },
                        timezone: "Etc/UTC",
                        error: error_handler,            
                        dataSource: {
                            timezone: "Etc/UTC",
                            batch: true,                
                            transport: {
                                read: {
                                    url: "GetCalendarEvents",
                                    contentType: "application/json; charset=utf-8",
                                    dateType: "json"
                                },
                                update: {
                                    url: "UpdateCalendarEvent",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json"
                                },
                                create: {
                                    url: "InsertCalendarEvent",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json"
                                },
                                destroy: {
                                    url: "DeleteCalendarEvent",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation === "read") {
                                        var scheduler = $("#scheduler").data("kendoScheduler");

                                        var result = {
                                            CreatedDate: new Date(new Date().getFullYear(), new Date().getMonth() - 6, new Date().getDate(), 0, 0, 0, 0), 
                                            EndDate: new Date(new Date().getFullYear(), new Date().getMonth() + 6, new Date().getDate(), 0, 0, 0, 0),
                                            Creator: 1378 // ToDo::                                
                                        }

                                        return { models: kendo.stringify(result) };
                                    }

                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            },
                            schema: {
                                model: {
                                    "id": "EventID",
                                    "fields": {
                                        "EventID": {
                                            "type": "number"
                                        },
                                        "InteractionID":{
                                            "type":"number"
                                        },
                                        "title": {
                                            "from": "Subject",
                                            "validation": { required: true }
                                        },
                                        "description": {
                                            "from": "Content"
                                        },
                                        "start": {
                                            "from": "CreatedDate",
                                            "type": "date"
                                        },
                                        "end": {
                                            "from": "EndDate",
                                            "type": "date"
                                        },
                                        "ownerId": {
                                            "from": "Creator",
                                            "type": "number"
                                        },
                                        "location": {
                                            "from": "Location",
                                            "type": "string"
                                        },
                                        "Attendees": {
                                            "type": "object"
                                        },
                                        "startTimezone": {
                                            "defaultValue": "Etc/UTC"
                                        },
                                        "endTimezone": {
                                            "defaultValue": "Etc/UTC"
                                        }
                                    }
                                }
                            }
                        }
                    });
                });

1 个答案:

答案 0 :(得分:0)

解决方案是在实体类中以UTC格式设置CreatedDate和EndDate。

css/
   sass/
       theme/
            _some-style.scss
            _some-style-2.scss
            _some-style-3.scss
       style.scss
   style.css
   style.css.map

此外,不需要在DataSource和Schema中设置timeZone。只是在Scheduler级别应该没问题。

希望有所帮助。