【问题标题】:DHTMLX Gantt dates converting to objectsDHTMLX 甘特图日期转换为对象
【发布时间】:2020-06-17 08:39:17
【问题描述】:

我有一个基本的甘特图,其中包含一组项目,每个任务看起来像这样:

{
   text: "test title"
   start_date: "2020-03-21"
   end_date: "2020-03-27"
   projectNumber: "3525"
   id: 95
}

我的 date_format 设置如下: gantt.config.date_format = '%Y-%m-%d';

数据加载正常,图表填充了数据,但是当我通过 Id 获取任务或显示所有图表任务时,输出将日期显示为对象,而不是像我最初设置的字符串那样。这是一个示例输出:

text: "test"
start_date: Sat Mar 21 2020 00:00:00 GMT-0400 (Eastern Daylight Time) {}
end_date: Fri Mar 27 2020 00:00:00 GMT-0400 (Eastern Daylight Time) {}
projectNumber: "48"
id: 9
progress: 0
$no_start: false
$no_end: false
$rendered_type: "task"
duration: 6
$source: []
$target: []
parent: 0
$rendered_parent: 0
$level: 0
$open: false
$index: 0

为什么开始和结束日期字符串的格式与我插入它们时的格式不同?这是甘特图的默认行为吗?

【问题讨论】:

    标签: angular dhtmlx


    【解决方案1】:

    是的,这是设计使然。甘特图直接使用日期对象。如果要将数据保存在 JSON 变量中,可以使用gantt.serialize() 方法,日期将转换为字符串:

    https://docs.dhtmlx.com/gantt/api__gantt_serialize.html

    http://prnt.sc/rdprin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      • 2016-07-22
      • 1970-01-01
      • 2011-06-03
      • 2016-05-25
      • 1970-01-01
      • 2015-12-05
      相关资源
      最近更新 更多