项目管理工具dhtmlxGantt甘特图入门教程(八):数据加载(二)

这篇文章给大家讲解如何利用dhtmlxGantt加载任务日期。

点击获DhtmlxGantt官方正式版

加载任务日期

设置任务计划

可以通过三种方式为数据馈送中的任务定义计划:

  • 开始日期 + 持续时间
  • 开始日期 + 结束日期
  • 持续时间 + 结束日期

未指定的属性将根据数据对象中定义的属性进行计算。

end_date的优先级高于duration参数。如果任务对象中指定了3个参数,甘特图将忽略持续时间参数,任务将加载不同的持续时间值。例如:

{
    "id":"20", "text":"Project #2", 
    "start_date":"01-04-2025", 
    "duration":3, 
    "end_date":"05-04-2025", 
    "order":10,"progress":0.4, 
    "type": "project", "open": true
}
 
// the task above will be loaded with the duration value calculated in accordance
// with the specified 'start_date' and 'end_date'
{
    "id":"20", "text":"Project #2", 
    "start_date":"01-04-2025", 
    "duration":4, 
    "end_date":"05-04-2025", 
    "order":10,"progress":0.4, 
    "type": "project", "open": true
}

以ISO格式加载日期

您可以在甘特图中使用ISO日期格式。为此,您需要重新定义在甘特图中解析和序列化日期的函数:

gantt.templates.parse_date = function(date) { 
    return new Date(date);
};
gantt.templates.format_date = function(date) { 
    return date.toISOString();
};

dhtmlxGantt是用于跨浏览器和跨平台应用程序的功能齐全的Gantt图表,可满足项目管理应用程序的所有需求,是最完善的甘特图图表库。了解更多DhtmlxGantt相关内容,请锁定本套系列教程。

你可能感兴趣的:(项目管理工具,项目管理控件,甘特图,dhtmlxgantt,gantt)