- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
要开始使用 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,格式为:
[{"Title":"meeting","TaskId":"00U410000059ZjbEAE","StartTimezone":"Etc/UTC","Start":"2017-01-26", "RecurrenceRule":null, "RecurrenceId":null, "RecurrenceException":null, "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":null, "RecurrenceException":null, "OwnerId":"005410000020eU9AAI", "IsAllDay":false, "EndTimezone":"Etc/UTC", "End":"2017-01-26", "Description":"a meeting"}, etc...}]
根据console.log(data)中的读取操作。我有一个 Controller ,它获取事件数组,然后 JSON.serializes 该数组(这是 JSON 字符串,用于数据访问)。
我不明白时区偏移的问题是什么,我所有的 JSON 条目数据都与教程架构的字段匹配,但它仍然不起作用...我只需要日历来显示当前的所有事件通过将此 JSON 传递给读取操作来打开它时存在。任何帮助将非常感激!谢谢。
这是我的 Controller :
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;
}
}
我获取事件列表,然后使用自定义类创建一个新列表,将原始事件列表中的数据绑定(bind)到数据名称与教程中的架构模型名称匹配的事件。我还将所有“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);
}
其中数据是我的剑道调度程序事件数组。现在,我的日程安排显示了我的组织中的所有事件。现在我需要进行更新、销毁和创建操作:)。已接受答案的评论中提供的链接帮助我通过必要的文档找到了此解决方案。
最佳答案
正如我在评论中提到的,此问题可能还有其他原因,但查看代码,其中一个错误是模型配置不正确以及读取配置不正确
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 网站上的这个基本示例。
http://demos.telerik.com/kendo-ui/scheduler/index
正确的读取配置
请使用此阅读我不确定您的 Controller 是否返回正确的数据并且您的绑定(bind)不正确
read: { url: "demos.telerik.com/kendo-ui/service/tasks";, dataType: "jsonp" }
关于javascript - Kendo-UI 调度程序 'GetTimezoneOffset' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41918051/
getTimezoneOffset() 方法返回UTC 时间与本地时间之间的时差(以分钟为单位)。 如果我在加利福尼亚州,并且使用的太平洋标准时间,比 (GMT -8) 和 (GMT -7) 晚 8
我知道 Date 对象正在使用机器时区(代码运行的地方)。我有一个特定的用例,需要清除偏移量。 var d = new Date(); console.log(d.getTimezoneOffset(
服务器中存储的日期为 GMT+0,没有夏令时。 客户端应该以自己的时区格式接收它。因此我们可以获取时区偏移量并将其与接收日期进行汇总: const currentTime = new Date();
我有一个函数,可以根据澳大利亚新南威尔士州时区减去本地偏移来计算当前用户位置时间。因此,例如,我想比较澳大利亚 (NSW) 本地时间和我本地时间的事件开始时间,如果我在我的本地主机上打开网站,我会得到
我想知道 Date.prototype.getTimezoneOffset() 如何获取主机系统的时区设置。 据我所知,出于安全原因,浏览器中的 JavaScript 是在沙盒环境中执行的。它如何检索
我的客户端的浏览返回时区偏移值是1020。它有效吗?如果有效,它是什么 Etc/GMT 区?非常感谢。 最佳答案 如果它是 +1020,那么在 UTC 中就是 -17(以前称为 GMT,在 Colle
我电脑的时区是 GMT-7:00 美国和加拿大山区时间。我在 w3cschool 上尝试了一个 javascript 示例: var d=new Date() var gmtHours = -d
我在 Javascript 中的转换逻辑下面有日期时间,它将 UTC 时间转换为传递时区的本地时间。我想知道这个逻辑在日光转换期间是否可以正常工作?如果不是的话有什么补救办法?我无法使用任何第三方库。
有没有办法让这个函数返回时区偏移量并考虑夏令时? 例如,我们位于罗马尼亚,格林威治标准时间(伦敦时间)前 2 小时。但此函数返回 -180(-3 小时)而不是 -120(-2 小时)。 http://
例如我有这个: d = new Date(2013,04,20,14,56,10) Mon May 20 2013 14:56:10 GMT+0800 (SGT) dt = d.getTime() /
更新:请参阅下面的原始帖子。 开始原创帖子 如果用户在聊天时间之外访问该网站,则正在努力将客户的聊天按钮更改为“离线模式”。 工作时间为周一至周五上午 9 点至下午 5 点东部时间(美国时间,而非澳大
在我的浏览器(firefox)中,我执行了这个简单的代码: new Date().getTimezoneOffset(); new Date(1444824485080).getTimezoneOff
我的浏览器在东部标准时区运行,当我调用 date.getTimezoneOffset() 时,我希望返回 -300,但我得到的是 300 var date = new Date(); date.get
令我惊讶的是 new Date().getTimezoneOffset() 返回与 moment().utcOffset() 相反的内容 示例: 时区 UTC +08:00 香港 JS:-480 时刻
Date.getTimezoneOffset 的文档说: Deprecated. As of JDK version 1.1, replaced by -(Calendar.get(Calendar.
documentation似乎建议 getTimezoneOffset() 总是返回当前语言环境的偏移量,而不管日期对象如何。但是我得到的结果不一致,我无法理解。 new Date().getTime
我的代码中的以下行: var timezoneoffset = new Date().getTimezoneOffset(); 返回 -120.14933013916015。 我原以为返回值为 120
我的服务器收到一个 JSON 响应,以秒为单位提供 UTC Unix 时间戳。我将其解析为将在图表中使用的 JavaScript 日期(在用户的语言环境中显示时间)。 我显然必须将我拥有的时间戳(以
我正在尝试将操作系统的 GMT 时间偏移与 Javascript 的 Date.getTimezoneOffset() 的 GMT 时间偏移进行比较。问题是 windows 给出了基于 EST 的偏移
new Date().getTimezoneOffset()*(-1); 此 JS 函数以分钟为单位返回机器的 UTC 时区。有没有PHP函数做同样的事情? 谢谢.. 最佳答案 ACCORDING T
我是一名优秀的程序员,十分优秀!