Our state of the art Gantt chart


Post by dmitrypromx »

Hello,
We use React's State hook (useState) to store and update values for tasks.
And we want to implement functionality to update start and end dates of the task.
There is no problem in updating the endDate, I just set a new value to the endDate and see the changes in the UI but when I update the startDate, I see that Start Date is changed for a moment but than it reverts back to the initial value.
Could you please help me to find a right way hot to properly update startDate value for a task?

    const [tasksState, setTasksState] = useState<TaskModel[] | Partial<TaskModelConfig>[]>([]);
    useEffect(() => {
        const tasks = [
            {
                "id": 1,
                "name": "Setup web server",
                "percentDone": 50,
                "startDate": "2023-05-11",
                "rollup": true,
                "endDate": "2023-05-31",
                "expanded": true,
                "baselines": [
                    {
                        "startDate": "2023-05-13T23:00:00",
                        "endDate": "2023-05-16T23:00:00"
                    },
                    {
                        "startDate": "2023-05-13T23:00:00",
                        "endDate": "2023-05-16T23:00:00"
                    },
                    {
                        "startDate": "2023-05-13T23:00:00",
                        "endDate": "2023-05-16T23:00:00"
                    }
                ]
            }
        ];
        setTasksState(tasks);
    }, [])

const clickHandler = () => {
    const tasks = tasksState.map(t => t.id === 1 ? { ...t, startDate: '2023-05-20' } : t);
    setTasksState(tasks);
}
            <BryntumGantt
                ref={gantt}
                tasks={tasksState}
                {...ganttConfig}
            />

Post by alex.l »

Hi, startDate of a task cannot be changed to any value because Gantt is scheduling all tasks automatically. startDate depends on many factors, such as dependencies, constraints, project's scheduling direction. If you want to have manual startDate for a task, you need to use one of these instruments or make it manuallyScheduled.

All these processes and more are described in our guide here https://bryntum.com/products/gantt/docs/guide/engine/gantt_events_scheduling

All the best,
Alex


Post by dmitrypromx »

Hi Alex. Thank you for a quick reply. But why then can I manually update the start date via the task edit form? I want to achieve the same functionality programmatically.

GanttStartDate.png
GanttStartDate.png (233.34 KiB) Viewed 99 times

Post by dmitrypromx »

Alex, after setting "manuallyScheduled" = true for a task, I can update both startDate and endDate values. Thank you for your help.


Post Reply