groups tasks by the specified task's attribute
config | GroupConfig | boolean | the grouping configuration object, or false to ungroup tasks |
Available only in PRO Edition
// one-level grouping
gantt.groupBy({
relation_property: "priority",
groups: [
{key:0, label: "High"},
{key:4, label: "Normal"},
{key:5, label: "Low"},
],
group_id: "key",
group_text: "label",
save_tree_structure: true
});
//multi-level grouping
gantt.groupBy({
relation_property: "priority",
groups: [
{key:0, label: "High"},
{key:4, label: "Normal"},
{key:5, label: "Low"},
// multi level groups
{key:1, label: "Give High Attention", "priority":0},
{key:2, label: "Resolve Immediately", "priority":0},
{key:3, label: "Keep For Next Release", "priority":5}
],
group_id: "key",
group_text: "label"
});
// using collections
gantt.serverList("priority", [
{key:1, label: "High"},
{key:2, label: "Normal"},
{key:3, label: "Low"}
]);
gantt.groupBy({
groups: gantt.serverList("priority"),
relation_property: "priority",
group_id: "key",
group_text: "label"
});
// ungrouping tasks
gantt.groupBy(false);
This functionality is available in the PRO edition only.
This method is defined in the grouping extension, so you need to activate the grouping plugin. Read the details in the Grouping Tasks article.
The grouping configuration object has the following properties:
Please, note:
The "id" value is not allowed, since when Gantt is grouping tasks, it creates virtual group tasks and adds the 'group_id' and 'group_text' parameters into these tasks. It means that by default the grouped tasks will have the 'key' and 'value' properties. At the same time, each task already has the 'id' property and changing the default ids of tasks will lead to the breakage of the tree structure.
gantt.templates.task_class=function(start, end, task){
if(task.$virtual)
return "summary-bar";
};