Our state of the art Gantt chart


Post by hakhtar »

Hi Support,

I need assistance achieving:

  • The task duration can be shorter than the project.

If the user wants to extend the task, it should change the parent's duration too. But shortening the task duration should not affect the parent's duration.
Need similar behavior between subtask and task.


Post by arcady »

That can be done by overriding end date calculation code like this:

export class Task extends TaskModel {

    ...

    // Overwrite sndDate calculation
    * calculateEndDatePure() {
        const manuallyScheduled   = yield this.$.manuallyScheduled;
        const hasSubEvents        = yield * this.hasSubEvents();

        // if that's a parent task and it's not manually scheduled
        if (!manuallyScheduled && hasSubEvents) {
            // get max children end date
            const childrenDate = yield * this.calculateMaxChildrenEndDate();
            // get this task current end date
            const previousValue = yield ProposedOrPrevious;

            // use max children end date if it's > current value
            return childrenDate > previousValue ? childrenDate : previousValue;
        }
        else {
            return yield * super.calculateEndDatePure();
        }
    }

}

And if you want a parent task to be completely independent from its children you can make it manually scheduled:
https://www.bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-manuallyScheduled


Post by hakhtar »

Thanks.
I don't need it completely independent from parent tasks. Need to change the duration only if the task exceeds its parent. Can we do it using ProjectModel Class. I am using Gantt in functional components with typescript.


Post by alex.l »

Hi hakhtar,

I don't need it completely independent from parent tasks.

In this case don't set https://www.bryntum.com/products/gantt/docs/api/Gantt/model/TaskModel#field-manuallyScheduled and use override Arcady provided as a start point to implement the logic you need.

Can we do it using ProjectModel Class.

This is a logic of TaskModel, not ProjectModel class. Yo will need to set your custom modelClass for your project as in our examples https://bryntum.com/products/gantt/examples/advanced/

     project : {
        // Let the Project know we want to use our own Task model with custom fields / methods
        taskModelClass : Task,

All the best,
Alex


Post by hakhtar »

The requirement has been met successfully. Thank You.


Post Reply