簡體   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