Hello Paul,
Here is the explanation of how the grouping extension works.
If you have the String
or Number
value in the group property, Gantt will create group tasks from the serverList
. The tasks that have the group property will be moved under these group tasks. Other tasks will be moved outside all groups. This is what you see in the snippet.
If you have the Array
or Object
value in the group property, Gantt will create only the group tasks from the serverList
that have at least one child. The tasks that have the group property will be moved under these group tasks. Other tasks will be moved under the default
group.
You can see how it works in the updated snippet:
https://snippet.dhtmlx.com/oxduyuvd
The dev team will fix that difference in the future.
Right now, there is no way to save the tree structure when you group tasks. Because of that, you cannot use the functionality of the split tasks when the tasks are grouped.
The dev team will add that feature in the future, but I cannot give you any ETA.
Also, when that feature is implemented, the subitem
tasks will still be moved to the default group or outside the groups, because they don’t match any group. If you want to change how it works, you need to implement a custom solution.
The other issue with the displayed value is related to the Gantt configuration.
In the grid, you use only 2 columns that have the "something"
and "columnB"
values in the name
parameter. And you don’t use the template
function in the column configuration. So, Gantt returns the values of the something
and columnB
properties in the Task
object. The group tasks don’t have these properties, so you see an empty string. The name of the group task is assigned to the text
property, as it is a mandatory property:
https://docs.dhtmlx.com/gantt/desktop__loading.html#dataproperties
You need to manually add the properties you need to the group tasks after grouping tasks:
gantt.batchUpdate(function () {
gantt.eachTask(function (task) {
if (task.$virtual) {
task.something = task.label;
}
})
})
Or you need to use the template
function in the column configuration to return the data or HTML elements you need:
https://docs.dhtmlx.com/gantt/desktop__specifying_columns.html#datamappingandtemplates
Here are the snippets:
https://snippet.dhtmlx.com/j0xlmyob
https://snippet.dhtmlx.com/0dph46ww
The data displayed in the task elements in the timeline is defined by the task_text
template:
https://docs.dhtmlx.com/gantt/api__gantt_task_text_template.html
By default, Gantt returns the value from the text
property. To see a different value, you need to modify the template:
gantt.templates.task_text = function (start, end, task) {
if (task.$virtual) {
return task.label;
}
else {
return task.something
}
};
Here is the snippet
https://snippet.dhtmlx.com/i1woim64