Incorrect Resource Chart Data After Using groupBy

Example URL: DHTMLX Snippet Tool

Data structure:
Task #1 is assigned to John, with dates from 03 Apr to 05 Apr

{
    "id": "ass01",
    "start_date": "03-04-2024 00:00",
    "duration": 1,
    "end_date": "04-04-2024 00:00",
    "delay": 0,
    "value": 8,
    "resource_id": "6",
    "mode": "fixedDuration"
},
{
    "id": "ass02",
    "start_date": "04-04-2024 00:00",
    "duration": 1,
    "end_date": "05-04-2024 00:00",
    "delay": 1,
    "value": 7,
    "resource_id": "6",
    "mode": "fixedDuration"
},
{
    "id": "ass03",
    "start_date": "05-04-2024 00:00",
    "duration": 1,
    "end_date": "06-04-2024 00:00",
    "delay": 2,
    "value": 6,
    "resource_id": "6",
    "mode": "default"
}

When clicking the group button, two issues arise:

  1. The Gantt chart grid shows “John, John, John” as the group, but this task is only assigned to John, so it should be in John’s group only.
  2. The resource chart data is incorrect. During the execution of the template function, the parameter data is incorrect. When rendering the cell for 03 Apr, the assignments parameter contains 3 records: one with the assignment ID ass01 and two others with the same data but with temporary IDs. For 03 Apr and 05 Apr , the parameter data is empty.


Is there a solution for these issues? Or am I using the method incorrectly?

Thank you!

Hello,
The group extension expects that the relation property has different values, duplicates (the task is not assigned to the same group several times). If a task belongs to several groups, Gantt creates a group with the common name:

When the process_resource_assignments config is enabled (by default), Gantt stores the resource assignments in the resource property.
You have 3 assignments of the same resource to that task, and that’s why it shows the 6,6,6 key with the John,John,John name. If there were different assignments, it could have been the 3,5,6 key with the Anna,Floe,John name.

When you group tasks, Gantt removes existing tasks and creates a new dataset with a different tree structure. When you group by a resource property, Gantt generates new assignments basing on the old assignment, the group key, and the resource_id property. But as the group key is duplicated, Gantt duplicates the assignments as well.
As a result, you no longer have the previous assignments, and there is no way to restore them.

The group extension doesn’t expect the same values that you have in the assignments (because of the resource_id property), so, this is not a Gantt issue.
Gantt works the same way if you have the duplicate values:
https://snippet.dhtmlx.com/c99bpfic

However, I think, it is not expected behavior that the resource assignments are changed after you group tasks. So, I will add it as a bug.

I think, right now, there is no proper way to group tasks by resources if a task has different assignments of the same resource.
I will let the dev team know about that.

As a workaround, you can get all resource IDs and save them in a separate property. Then you need to remove the duplicate values. After that, you need to assign the new array to a task property and group by that property.
Here is the updated snippet:
https://snippet.dhtmlx.com/elgidnsu

1 Like