gantt-task-react icon indicating copy to clipboard operation
gantt-task-react copied to clipboard

Add task dynamically

Open akshatgupta02 opened this issue 3 years ago • 2 comments

Is it possible to add new tasks dynamically or to delete tasks. Also, would be good if there is support to have scheduling tasks by priority from UI itself.

akshatgupta02 avatar Sep 03 '21 21:09 akshatgupta02

Updating the tasks via setTasks will cause a rerender of the chart.

  useEffect(() => {
    setTimeout(() => {
      // make copy of tasks otherwise it will not cause a re-render of chart
      const nt = [...tasks];
      const currentDate = new Date();
      // add the item to the array but could easily be updating an item
      nt.push({
        start: new Date(currentDate.getFullYear(), currentDate.getMonth(), 25),
        end: new Date(currentDate.getFullYear(), currentDate.getMonth(), 26),
        name: "Party Time 2",
        id: "Task 10005",
        progress: 0,
        isDisabled: true,
        type: "task",
      });
      // set tasks
      setTasks(nt);
    }, 5000);
  }, []);

Graeme43 avatar Apr 26 '22 04:04 Graeme43

Updating the tasks via setTasks will cause a rerender of the chart.

any solution for rerender of the chart ?

OguzEkinci avatar Feb 06 '23 13:02 OguzEkinci