search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Collapse task in DayPilot.Gantt

Asked by Leo
1 month ago.

How do you collapse a row/task in DayPilot.Gantt?

In the API docs it refers to the methods collapse() and toggle(), however I always receive errors like TypeError: row.collapse is not a function

My code is as follows:

this.gantt.tasks.list.forEach((row: any) => {
 row.collapse();
});

Using the following does not work either:

this.gantt.tasks.find(row.id).collapse();

Am I missing something?

Thank you!

Answer posted by Dan Letecky [DayPilot]
1 month ago.

The tasks.list array holds the raw data objects (they don’t have any methods).

The method you need is DayPilot.Task.row.collapse(). You can call it like this:

this.gantt.tasks.find(row.id).row.collapse();
Comment posted by Anonymous
1 month ago.

can you elaborate on what the call is supposed to look like? because when i create my gantt like this:


            const dp = new DayPilot.Gantt("dp", {
                cellWidthSpec: "Fixed",
                cellWidth: 40,
                timeHeaders: [{ "groupBy": "Month" }, { "groupBy": "Day", "format": "d" }],
                scale: "Day",
                taskHeight: 25,
                rowHeaderHideIconEnabled: true,
                rowMoveHandling: "Disabled",
                taskMoveHandling: "Disabled",
                linkCreateHandling: "Disabled",
                rowCreateHandling: "Disabled",
                heightSpec: "Max",
                taskGroupMode: "Manual",
                startDate: DayPilot.Date.today(),
                days: 30,
                height: window.innerHeight - 260,
            });

And call the function you specified like this:

console.log(dp.tasks.find('Obj-AVC-010'))


I get null even though the id i entered does exist in the tasks list and is even a parent element

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.