Our state of the art Gantt chart


Post by attila.posta »

Hi!

Before adding records to dependencyStore, how can I check if it would be valid / non-circular?
I don't want to let the cycle popup come up, I simply need a boolean value to decide what to do next.

    this.gantt.project.dependencyStore.add({
      id: this.uuid.getUuid(),
      fromEvent: source.id,
      toEvent: target.id,
      type: DependencyType.EndToStart,
      fromSide: 'right',
      toSide: 'left',
    });
    await this.gantt.project.commitAsync();

I'm using Gantt 5.1.4.

regards,
Norbi


Post by arcady »

That can be checked with this method: https://www.bryntum.com/products/gantt/docs/engine/classes/_lib_engine_quark_model_gantt_ganttprojectmixin_.ganttprojectmixin.html#validatedependency

It's a method coming from the Engine class which ends up on the Gantt ProjectModel. I doubt it appears in TypeScript interface the Gantt ships but rest assured it is there on the model:

const dependencyError = await project.validateDependency(task1, task2, DependencyModel.Type.EndToStart);

The method returns a Promise which when resolved provides values: 0 - dependency is ok, 1 - it builds a cycle, 2 - it duplicates an already existing dependency


Post by attila.posta »

Worked, thanks.


Post Reply