Resize parent task timelines based on visible children

Hi, I am using gantt to display a project timeline. I’ve built functionality that allows users to filter out groups of tasks based on various critieria. Here is an example (scroll to the right to see the important parts):


I do this using code that looks like this:

gantt.attachEvent("onBeforeTaskDisplay", function(id, task) {
var productsAndReleasesToShow = $("#productTree").fancytree('getRootNode').tree.getSelectedNodes() || [];

// If empty, show everything
if (productsAndReleasesToShow.length === 0) {
return true;
}

var idsOfproductsAndReleasesToShow = extractIdsFromProductsAndReleases(productsAndReleasesToShow);

var tasksToShow = findTasksAlignedToProductsAndReleases(gantt, idsOfproductsAndReleasesToShow);

return taskOrParentTaskOrChildTaskIsOneOfTasksToShow(gantt,
tasksToShow, task);
});

The problem is that when I hide these tasks, I want to shrink the parent task timeline, but that doesn’t seem to happen, even when I use gantt.resetProjectDates(task); .

(scroll to the right to see the important parts)


Is this because I am hiding tasks vs completely removing them? What is the best way to enable this behavior?

Here’s a snippet that shows a simplified version:

docs.dhtmlx.com/gantt/snippet/ef73116c

Hi,
unfortunately, there is no built-in way to do so.
As a workaround you can redefine method that calculates duration of subtasks for a certain parent
github.com/DHTMLX/gantt/blob/4. … t.js#L5964

E.g. please check following:
docs.dhtmlx.com/gantt/snippet/5e193e82
It seems working as expected, however, sometimes overriden methods may come in conflict with built-in logic - I can’t guarantee that such modification won’t work as required in all cases.

Also please note that in order item to have auto-calculated dates and duration it should have type=‘project’, since regular tasks have individual dates which won’t be affected by resetProjectDates.
docs.dhtmlx.com/gantt/desktop__ … ojecttasks