Closed vxhly closed 3 years ago
Hello, Please, ask the questions in English.
Support timestamp, that is, start_date and end_date. If it is a timestamp, how to configure it (the timestamp returned by the back-end can not be traversed and modified on the front-end side)
Gantt uses the Date object for the start_date
and end_date
properties of the task
object. You can easily convert it to the timestamp the following way:
let timestamp = +task.start_date // same as +new Date()
But there is no way to change how Gantt stores the dates.
If you server saves the date values as a timestamp, you need to convert them the following way:
gantt.attachEvent("onTaskLoading", function(task){
task.start_date = new Date(timestamp_start_date);
task.end_date = new Date(timestamp_end_date);
return true;
});
Support end time end_date, end_date seems to be unsupported by default, you have to use the duration field (the backend returns two fields start_date and end_date, you can’t calculate it manually)
Each regular task should have at least 2 date parameters: start_date
, end_date
, duration
. These are mandatory properties:
https://docs.dhtmlx.com/gantt/desktop__loading.html#dataproperties
If you load tasks with the start_date
and duration
parameters, Gantt will calculate the end_date
.
If there are all three date parameters or only the start_date
and end_date
parameters, Gantt will ignore the duration
parameter and calculate it from the start_date
and end_date
parameters.
To manually calculate the dates and duration, you can use the calculateEndDate
and calculateDuration
methods:
https://docs.dhtmlx.com/gantt/api__gantt_calculateenddate.html
https://docs.dhtmlx.com/gantt/api__gantt_calculateduration.html
Don’t want the extra time points in the figure below, how to configure
By default, Gantt adds a day for each side of the chart so that you will be able to drag a task.
To change it, you need to specify the gantt.config.start_date
and gantt.config.end_date
parameters:
https://docs.dhtmlx.com/gantt/api__gantt_start_date_config.html
Here are examples of how it can be done:
http://snippet.dhtmlx.com/5/e69a591a8
http://snippet.dhtmlx.com/5/858592cb9
我二次封装的dhtmlx-gantt 的组件如下:
由于对dhtmlx-gantt 的配置不太熟悉,以及官方文档又是英文的,找起来比较吃力,所以想来问问有没有改善的方法
需要改进的地方,