backward planning - task instead of start_date use end_date

Hey,
for backward planning I would like to create a task with the property end_date instead of start_date.

Is there a way to use DhtmlxGantt with backward planning tasks ?

Thanks in advance.
Frank

Hello,
client-side component supports only ‘start_date + duration’ or ‘start_date + end_date’ timings. So unfortunately defining time with end date is currently not possible.

However, if you willing to customize the component, probably you could achieve this with some amount of coding.

You may try to override function that initializes task time (gantt._init_task). In the current implementation it only does so if task have start_date defined.

github.com/DHTMLX/gantt/blob/v2 … t.js#L5143

Probably if you add following ‘else if’ statement, gantt will be able to load tasks in your format.
github.com/DHTMLX/gantt/blob/v2 … t.js#L5158

if(task.start_date){ if(!task.end_date && task.duration){ task.end_date = this.calculateEndDate(task.start_date, task.duration); } }else if(task.end_date){ task.start_date = this.calculateEndDate(task.end_date, - task.duration); }
Please note, this code hasn’t been tested and I can’t guarantee that it will work as expected. You also will need to implement lightbox controls for setting end-date and duration, since the current ones are binded to the start date.
If you are going to modify these method, do not do it in source files themselves, since the would become incompatible with future updates. You can define all methods in a separate JS file and load it after dhtmlxgantt.js, so it overwrite needed methods.

1 Like

Hi Aliaksandr,

thank you very much! I did it as you suggested.

Wow that did the trick. It is a great Framework.

Thanks a lot.

Happy easter! :smiley: