繁体   English   中英

Kendo-UI调度程序“ GetTimezoneOffset”错误

[英]Kendo-UI Scheduler 'GetTimezoneOffset' Error

要开始使用Kendo UI处理日历,我首先要从Salesforce组织中提取事件,然后将其显示在时间表上。 但是,我受到“无法读取未定义错误的属性'getTimezoneOffset'的困扰,正在寻求帮助。我的JS是:

var data = '{!jsonString}';
       var scheduler = $('#scheduler').kendoScheduler({
       date: new Date(),
       startTime: new Date(),
       height: 700,
       timezone: "Etc/UTC",
       views: [
          {type: "week", selected: true},
          "week",
          "month",
          "agenda"
       ],
       dataSource: {
          batch: true,
          transport: {
              read: function(e){
                  console.log(data);
                  e.success(data);
              },
              update: {
                  url: "http://demos.telerik.com/kendo-ui/service/tasks/update",
                  dataType: "jsonp"
              },
              create: {
                  url: "http://demos.telerik.com/kendo-ui/service/tasks/create",
                  dataType: "jsonp"
              },
              destroy: {
                  url: "http://demos.telerik.com/kendo-ui/service/tasks/destroy",
                  dataType: "jsonp"
              },
              parameterMap: function(options, operation) {
                  if (operation !== "read" && options.models) {
                      return {models: kendo.stringify(options.models)};
                  }
              }
          },
          schema: {
              model: {
                  id: "OwnerId",
                  fields: {
                       taskId: { from: "TaskID" },
                       title: { from: "Title", defaultValue: "No title", validation: { required: true } },
                       start: { type: "date", from: "Start" },
                       end: { type: "date", from: "EndTime" },
                       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" }
                  }
              }
          }
      }
                        //});
  });

并且数据变量是JSON,格式为:

[{“标题”:“会议”,“ TaskId”:“ 00U410000059ZjbEAE”,“ StartTimezone”:“ Etc / UTC”,“开始”:“ 2017-01-26”,“ RecurrenceRule”:null,“ RecurrenceId”: null,“ RecurrenceException”:空,“ OwnerId”:“ 005410000020eLnAAI”,“ IsAllDay”:false,“ EndTimezone”:“ Etc / UTC”,“ End”:“ 2017-01-26”,“ Description”:“ a Meeting“},{” Title“:” meeting“,” TaskId“:” 00U410000059ZjcEAE“,” StartTimezone“:” Etc / UTC“,” Start“:” 2017-01-26“,” RecurrenceRule“:null,” RecurrenceId”:空,“ RecurrenceException”:空,“ OwnerId”:“ 005410000020eU9AAI”,“ IsAllDay”:false,“ EndTimezone”:“ Etc / UTC”,“ End”:“ 2017-01-26”,“ Description” :“会议”},等等...}]

根据console.log(data)中的读取操作。 我有一个获取事件数组的控制器,然后将其序列化为JSON.serialize(该数组是数据访问的JSON String)。

我不知道时区偏移是什么问题,我的所有JSON条目数据都与教程模式的字段匹配,但仍然无法正常工作...我只需要日历显示当前存在的所有事件(当它存在时)通过将此JSON传递给读取操作来打开。 任何帮助将不胜感激! 谢谢。

这是我的控制器:

global with sharing class CalendarData {

public List<Event> eventList{get;set;}
public String jsonString{get;set;}
public List<schedulerItem> correctedItems{get;set;}

public CalendarData(){
    String eventQuery = 'SELECT ActivityDate,ActivityDateTime,CreatedById,Description,DurationInMinutes,EventSubtype,IsAllDayEvent,Location,OwnerId,EndDateTime,StartDateTime,Subject FROM Event';
    eventList = Database.query(eventQuery);
    correctedItems = itemList(eventList);
    system.debug(correctedItems);
    jsonString = JSON.serialize(correctedItems);
    jsonString = jsonString.replace('"EndTime"', '"End"');
}

public List<schedulerItem> itemList(List<Event> events){
        Integer i = 0;
        system.debug(events);
        List<schedulerItem> kendoEvents = new List<schedulerItem>();
        schedulerItem item = new schedulerItem();
        for(i = 0; i < events.size(); i++){
            item.Description = events[i].Description;
            Datetime dt = events[i].EndDateTime;
            item.EndTime = dt.date();
            dt = events[i].StartDateTime;
            item.Start = dt.date();
            item.EndTimezone = 'Etc/UTC';
    //public String id;
            item.IsAllDay = events[i].IsAllDayEvent;
            item.RecurrenceException = null; 
            item.RecurrenceId = null;
            item.RecurrenceRule = null;
            item.StartTimezone = 'Etc/UTC';
            item.Title = events[i].Subject;
            item.TaskId = events[i].Id;
            item.OwnerId = events[i].OwnerId;
            system.debug(item);
            kendoEvents.add(item);

            item = new schedulerItem();
        }
        return kendoEvents;
    }

public class schedulerItem{
    public String Description;
    public Date EndTime;
    public Date Start;
    public String EndTimezone;
    //public String id;
    public Boolean IsAllDay;
    public String RecurrenceException; 
    public String RecurrenceId;
    public String RecurrenceRule;
    public String StartTimezone;
    public String Title;
    public String TaskId;
    public String OwnerId;

}
}

我得到一个事件列表,然后使用一个自定义类创建一个新列表,以将原始事件列表中的数据绑定到数据名称与该教程中的架构模型名称匹配的事件。 我还将所有“ EndTime”替换为“ End”。

找到一种解决方案来读取我的事件:

var data = '{!jsonString}';
                var dataList = JSON.parse(data);
                function getNewEvents() {
                    var eventList = [];
                    for(var i = 0; i < dataList.length; i++){
                        //console.log("DataList Again: " + dataList[i]);
                        var kendoEvent = new kendo.data.SchedulerEvent({
                            id: i,
                            taskId: dataList[i].TaskId,
                            title: dataList[i].Title,
                            start: new Date(dataList[i].Start),
                            end: new Date(dataList[i].End),
                            startTimezone: dataList[i].StartTimezone,
                            endTimezone: dataList[i].EndTimezone,
                            description: dataList[i].Description,
                            recurrenceId: dataList[i].RecurrenceId,
                            recurrenceRule: dataList[i].RecurrenceRule,
                            recurrenceException: dataList[i].RecurrenceException,
                            ownerId: dataList[i].OwnerId,
                            isAllDay: dataList[i].IsAllDay
                        });
                        eventList.push(kendoEvent);
                    }
                    return eventList;
                }
                eventData = getNewEvents();

我使用返回的JSON数组,然后将其解析回对象数组,然后创建了一个实际的kendo.data.SchedulerEvents新数组,并使用正确的名称填充了所有字段。 然后在数据源的读取操作中,而不是URL和数据类型中,我做了:

read: function(e){
    e.success(data);
}

数据是我的Kendo Scheduler事件数组。 现在,我的日程表显示了我组织中的所有事件。 现在,我需要进行更新,销毁和创建操作:)。 接受的答案的注释中提供的链接帮助我通过必要的文档来实现此解决方案。

正如我在评论中提到的那样,可能还有其他原因导致此问题,但是调查代码中的错误之一是模型配置错误以及读取配置错误

JSON中没有作为EndTime的传入字段,而是End

EndTime更改为End以匹配传入的JSON字段声明

{"Title":"meeting","IsAllDay":false,"EndTimezone":"Etc/UTC","End":"2017-01-26", "Description":"a meeting"}

这是Fields声明

    fields: {
                           taskId: { from: "TaskID" },
                           title: { from: "Title", defaultValue: "No title", validation: { required: true } },
                           start: { type: "date", from: "Start" },
 // problem was here there is no EndTime as mentioned in the given code sample above .
// changed to End as it is in the incoming JSON
                           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" }
                      }

有关更多详细信息,请参阅telerik网站上的此基本示例。

http://demos.telerik.com/kendo-ui/scheduler/index

正确的读取配置

请使用此读取信息我不确定您的控制器是否返回正确的数据并且您的绑定不正确

read: { url: "demos.telerik.com/kendo-ui/service/tasks";, dataType: "jsonp" }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM