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

Removing all tasks from a gantt chart without disposing of it

Asked by Anonymous
18 days ago.

Hi,

I need to add functionality that will allow my users to choose between various types of data and then send their choice to a web service, returning the relevant set of tasks to populate the gantt with. For this, I need to remove all tasks from the gantt before populating it with the new ones.

I tried the following approaches:

dp.tasks.list.forEach(function (task) {
    dp.tasks.remove(new DayPilot.Task(task));
});

dp.tasks.list.forEach(function (task) {
    dp.tasks.remove(task);
});

But both did not work. I also tried iterating the tasks.list but its length doesn’t register for some reason and its elements are not Task objects anyway.
I’d appreciate some help.

Answer posted by Dan Letecky [DayPilot]
18 days ago.

When you need to load a new task set in the Gantt chart, the best way is to replace the tasks with a new array:

const tasks = [ /* ... */ ];
dp.update({tasks});

There is no need to clear the events first.

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):