а

Feature request: task range mode, auto adjusted


#1

Hello,

Recently we received a requirement from out client. They wanted to be able to specify if a task’s start_date and duration is calculated automatically (like a task of “project” type which expands automatically when you drag its children - lets call it “Mode 1”) or spcified manually (set via lightbox / dragging and resizing, like regular task - lets call it “Mode 2”). Initially, all tasks that contains a children should be in Mode 1, while all other tasks should be in Mode 2. Also, the mode changes automatically when you add first subtask (in this case mode of parent task should be set to Mode 1) or remove last subtask from the task (in such a case mode of parent task should change to Mode 2). Also, they wanted to be able to override mode in lightbox (for instance task with children can be in Mode 2 if they desired).

So, we added custom property “range” on task object and a radio button on the lightbox with two modes: “mode 1” and “mode 2”. We manupulate hidden properties: task.$no_start and task.$no_end. We also added handlers to onAfterTaskAdd and onBeforeTaskDelete to automatically change mode of parent task when last child is removed or first child is added. We had to make some workarounds to make it work properly, especially on the initial diagram load.

I was wondering if it’s possible to deliver such a feature to the Gantt diagram? Or maybe there is already a simpler way to do so?

We’re using the pro version of the library.

Regards, MP


#2

Hello Marcin,
There is the auto_types option:
https://docs.dhtmlx.com/gantt/api__gantt_auto_types_config.html
When you turn it on, Gantt changes the task types automatically. When you add a task, it is added in the Mode 2, when you add a child to it, Gantt changes the type to Project (Mode 1). When you delete all subtasks from a Project task, Gantt changes its type to Task (Mode 2).
Here is a ready sample that demonstrates how it works:
https://docs.dhtmlx.com/gantt/samples/04_customization/19_task_type.html

If that option doesn’t fit your needs, please clarify what is missing or what should be different.