jzzh
#1
Grouping by status works perfectly as described here:
https://docs.dhtmlx.com/gantt/desktop__grouping.html#groupingtasks
I also want to group by the task owner, but this is not a static list of keys.
Instead the list can be any of the 8000 persons in the database.
Can this be done?
Are there any examples how to do it?
Thanks,
Jochen
Hello,
You can pass the list of owners to the serverList
method, which allows you to update it dynamically:
gantt.serverList("owner", ownerList);
function groupBy(groups, relationProperty) {
gantt.groupBy({
groups: groups,
relation_property: relationProperty,
group_id: "key",
group_text: "label"
});
}
function groupByOwner() {
groupBy(ownerList, "owner");
}
Please see an example: DHTMLX Snippet Tool
jzzh
#3
Alright, thanks Maksim.
Can I load the persons from into data > collections ?
Actually its’ enough to load about 20 of the persons into a collection.
(The ones which are assigned in the project)
Hello,
Yes, you can. The collections
property in gantt.parse
can be used for this case:
const tasks = [ /* your project tasks */ ];
const ownerList = [
{ key: 101, label: "Alice" },
{ key: 102, label: "Bob" },
{ key: 103, label: "Charlie" }
// ... only the persons used in this project
];
const priorityList = [
{ key: 1, label: "High" },
{ key: 2, label: "Normal" },
{ key: 3, label: "Low" }
];
gantt.parse({
tasks: tasks,
collections: {
owner: ownerList,
priority: priorityList
}
});
// later you can update the list dynamically if needed
gantt.updateCollection("owner", newOwnerList);
After that, the collections are available through gantt.serverList("owner")
and gantt.serverList("priority")
Example: DHTMLX Snippet Tool