Calendar of the owner in the resource view


#1

Hi

I have a question regarding the gantt sample #3/11. When I switch the gantt into the resource view, I can see that for example task id: 6 (‘Air conditioners check’) has the ‘twoByTwo’ calendar (I can see it in the source code of the sample), because it is assigned to Mike (owner_id: 2). However the parent of this task, the “Mike task” has the global calendar. This is correct in terms of how the gantt is structured, because it is owned by the ‘department_2’ resource, which has global calendar. However I think this is not very logical in my opinion. If we have “Mike task” on the gantt, which represents user “Mike”, then this task should also have Mike’s calendar. What if I for example close the Mike’s branch? Then the only representation of the user Mike is his task on the gantt and it shows wrong (global) calendar. Is there some simple way around it?

Thank you very much for your help

Ondrej


#2

Hello Ondrej,
In that sample, the tasks are grouped:
https://docs.dhtmlx.com/gantt/desktop__grouping.html
https://docs.dhtmlx.com/gantt/api__gantt_groupby.html
When the tasks are grouped, the tasks with the parent type are not displayed. The group tasks that look like project tasks are virtual tasks. They are removed when you remove grouping, so, Gantt doesn’t apply additional settings to them. But you can modify these tasks by using the Gantt API:

    gantt.groupBy({ 
      groups: gantt.serverList("users"),       
      relation_property: "users",
      group_id: "key",
      group_text: "label"
    });
    gantt.batchUpdate(function(){
      gantt.eachTask(function(task){
        if (task.$virtual){
          var first_child_id = gantt.getChildren(task.id)[0];
          var child = gantt.getTask(first_child_id);
          task.users = child.users
          console.log(task.users)
          gantt.refreshTask(task.id)
        }
      })
    })

Here is an example where virtual tasks have the same calendar as their children:
http://snippet.dhtmlx.com/5/bc0394d92


#3

Hi Ramil,

thank you for your fast response and the proposed solution. This solution certainly works for the situation presented in your snippet. However there is one crucial difference between your snippet and the sample #3/11. In your snippet you are not using groups in the grouped mode (only users and tasks), while in the sample (as well as in my situation) the structure is group=>users=>tasks. This means that if I change the relation_property of the virtual task (like you do on the line “task.users = child.users” in the snippet), not only the resource calendar is changed, but also the hierarchy is updated and user virtual tasks are no longer children of the group virtual tasks (at least that was the case, when I tried it in my code). Can you please propose a solution if there are also groups included?

Thank you very much one more time and have a nice day!

Ondrej


#4

Hello Ondrej,
In the case of several tree levels in the grouped mode, it won’t help modifying the resource property as it is used as a relation property.
You can add the calendar_id property to the virtual task.
Here is the snippet with the code from the sample and where the virtual tasks are modified to match their children calendar:
http://snippet.dhtmlx.com/5/86661d442