Javascript 剑道UI调度程序';GetTimezoneOffset';错误

Javascript 剑道UI调度程序';GetTimezoneOffset';错误,javascript,json,salesforce,crud,kendo-scheduler,Javascript,Json,Salesforce,Crud,Kendo Scheduler,要开始使用剑道用户界面来处理日历,我首先从Salesforce组织中提取事件并在日程表上显示它们。然而,我被“无法读取未定义错误的属性'getTimezoneOffset'所困扰,正在寻求帮助。我的JS是: var data = '{!jsonString}'; var scheduler = $('#scheduler').kendoScheduler({ date: new Date(), startTime: new Date(),

要开始使用剑道用户界面来处理日历,我首先从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,格式如下:

[{“标题”:“会议”,“任务ID”:“00U410000059ZjbEAE”,“StartTimezone”:“Etc/UTC”,“开始”:“2017-01-26”, “RecurrenceRule”:null,“RecurrencereId”:null, “RecurrenceException”:null,“OwnerId”:“005410000020eLnAAI”, “IsAllDay”:假,“EndTimezone”:“Etc/UTC”,“End”:“2017-01-26”, “描述”:“会议”},{“标题”:“会议”, “任务ID”:“00U410000059ZjcEAE”,“StartTimezone”:“Etc/UTC”, “开始”:“2017-01-26”,“复发”:空,“复发ID”:空, “RecurrenceException”:null,“OwnerId:“005410000020eU9AAI”, “IsAllDay”:假,“EndTimezone”:“Etc/UTC”,“End”:“2017-01-26”, “说明”:“会议”}等..]

根据读取操作中的console.log(data),我有一个获取事件数组的控制器,然后JSON.log序列化该数组(即数据访问的JSON字符串)

我不明白时区偏移的问题是什么,我所有的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;

}
}

其中数据是我的剑道计划程序事件数组。现在,我的计划显示了我组织中的所有事件。现在我需要进行更新、销毁和创建操作:)。在接受答案的注释中提供的链接帮助我获得了此解决方案,并提供了必要的文档。

在我看来,这个问题可能还有其他原因注释中已分区,但查看代码时,其中一个错误是模型配置不正确以及读取配置不正确

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

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

{"Title":"meeting","IsAllDay":false,"EndTimezone":"Etc/UTC","End":"2017-01-26", "Description":"a meeting"}
这是字段声明

    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网站上的这个基本示例

正确的读取配置

请使用此读取,我不确定您的控制器是否返回正确的数据,以及您的绑定是否正确

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

正如我在评论中提到的,这个问题可能还有其他原因,但查看代码,其中一个错误是模型配置不正确以及读取配置不正确

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

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

{"Title":"meeting","IsAllDay":false,"EndTimezone":"Etc/UTC","End":"2017-01-26", "Description":"a meeting"}
这是字段声明

    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网站上的这个基本示例

正确的读取配置

请使用此读取,我不确定您的控制器是否返回正确的数据,以及您的绑定是否正确

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

“getTimezoneOffset of null”错误的最常见原因是错误地传递/设置了日期值。“getTimezoneOffset of null”错误的最常见原因是“错误传递/设置日期值不正确。感谢您的回复!但我将EndTime更改为“刚刚结束”,仍然得到错误。我的读取操作正确吗?这就是用本地json数组成功填充调度程序的方法吗?我无法找出错误:(读:{url:,数据类型:“jsonp”}我添加了我的控制器。另外,我最初让它与您刚刚发布的测试读取一起工作。但是,这会提取它们的预设事件。因此,在我获得这些事件后,我想更改读取操作,以使用本地数据填充计划(从salesforce组织检索到的json事件数组).好的,没问题。我会的。我真的很感谢你的帮助。我试图提高投票率,但它说这是有记录的,但对我来说没有公开:(我可能想知道这是否是因为当我将数组序列化为json时,它被“”单引号包围,并且在传递给读取时可能无法读取这些单引号?但是反序列化它只会将其还原为原始数组,而不是json数组。感谢您的回复!但是我将EndTime更改为just End,并且仍然得到错误。是吗我的读取操作正确吗?这就是用本地json数组成功填充调度程序的方法吗?我无法找出错误:(读取:{url:,数据类型:'jsonp'}我添加了我的控制器。另外,我最初让它与您刚刚发布的测试读取一起工作。但是,这会提取它们的预设事件。因此,在我获得这些事件后,我想更改读取操作,以使用本地数据填充计划(从salesforce组织检索到的json事件数组).好的,没问题。我会的。我真的很感谢你的帮助。我试图提高投票率,但它说这是有记录的,但对我来说没有公开:(我可能想知道这是否是因为当我将数组序列化为json时,它被“”单引号包围,并且在传递给读取时可能无法获得这些单引号?但是反序列化它只会将其还原为原始数组而不是json数组。