Our state of the art Gantt chart


Post by mv2022 »

When adding a new Task, is there a simple way of converting that task to a milestone?

For example, when a user clicks on onAddTaskClick(), instead of creating a task, I would like to create a milestone instead ? Thanks.

  public async onAddTaskClick(): Promise<any> {
    const
        gantt = this.gantt,
        added = gantt.taskStore.rootNode.appendChild({
          id: Guid.create().toString(),
          name: 'New task',
          duration: 1,
          system: this.storageService?.project?.System,
          worktype: this.storageService?.project?.DivisionName
        })
      ;
    gantt.features.cellEdit.startEditing({
      record: added,
      field: 'name'
    });
  }

Post by tasnim »

To achieve that you can use beforeAdd event and then set the duration to 0 it'll convert it to a milestone.
Please check the docs : https://bryntum.com/docs/gantt/api/Gantt/data/TaskStore#event-beforeAdd


Post by mv2022 »

I can't seem to get it to work. Would you be able to provide an example of how I might use this?

Also, it is possible to simply set the duration to 0 when creating a new task ? It seems to create a milestone rather than a task.

For example

 added = gantt.taskStore.rootNode.appendChild({
          id: Guid.create().toString(),
          name: 'New task',
          duration: 0, // does this create a milestone rather than a task now ?
          system: this.storageService?.project?.System,
          worktype: this.storageService?.project?.DivisionName
        })

Thanks


Post by tasnim »

Hi,
Sorry, I misunderstood you. You have your own button so just set the duration to 0. No need to listen to any events.

Best regards,
Tasnim


Post Reply