You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DHTMLX Scheduler内嵌数据无法加载问题求助

DHTMLX Scheduler无法加载内嵌数据的解决方案

你碰到的问题核心是日期格式不匹配导致Scheduler无法解析你的事件数据,而且还有个小细节是初始化日期和事件日期不在同一时间段,所以即使数据加载成功也看不到~ 我给你拆解下解决步骤:

问题原因

DHTMLX Scheduler默认的日期解析规则是月/日/年 时:分(格式标记为%m/%d/%Y %H:%i),但你提供的事件日期是日/月/年的格式,这就导致Scheduler识别不出这些日期,所以parse方法返回失败,弹出"NOK"提示。另外你初始化Scheduler用的是2019年1月20日,而事件都在2020年1月,就算数据加载成功,默认的周视图也看不到这些事件。

解决方法

方法1:修改日期为默认支持的格式

直接把事件里的日期改成月/日/年的格式,同时调整初始化日期到事件所在的时间段:

scheduler.init('scheduler_here', new Date(2020,0,15), "week");
if (scheduler.parse([
  {text:"Meeting", start_date:"01/15/2020 14:00", end_date:"01/15/2020 17:00"},
  {text:"Conference", start_date:"01/16/2020 12:00", end_date:"01/16/2020 19:00"},
  {text:"Interview", start_date:"01/17/2020 09:00", end_date:"01/17/2020 10:00"}
],"json")) {
  alert("OK");
} else {
  alert("NOK")
}

方法2:自定义日期解析格式

如果你不想修改现有数据的日期格式,可以提前配置Scheduler使用日/月/年的解析规则,同样别忘了调整初始化日期:

// 配置日期解析格式为日/月/年
scheduler.config.date_format = "%d/%m/%Y %H:%i";

scheduler.init('scheduler_here', new Date(2020,0,15), "week");
if (scheduler.parse([
  {text:"Meeting", start_date:"15/01/2020 14:00", end_date:"15/01/2020 17:00"},
  {text:"Conference", start_date:"16/01/2020 12:00", end_date:"16/01/2020 19:00"},
  {text:"Interview", start_date:"17/01/2020 09:00", end_date:"17/01/2020 10:00"}
],"json")) {
  alert("OK");
} else {
  alert("NOK")
}

这样修改后,你的事件就能正常显示在Scheduler里啦~

内容的提问来源于stack exchange,提问作者ps202

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:37:04