search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Angular Gantt Chart replace onrowcreate with button

Asked by Bcos
4 years ago.

Hi,
The current demo Gantt Chart is using bottom text field to create a new task
https://javascript.daypilot.org/demo/gantt/taskcreating.html

Is that any way to replace that bottom text field with a create button
After click that button will show the dialog box to input info and create a new task

Thank you.

Comment posted by Bcos
4 years ago.

Or just add a button anywhere to create a new gantt task

Answer posted by Dan Letecky [DayPilot]
4 years ago.

You can use your own button and add a new record to config.tasks property (Angular will detect the change) or you can use the direct API tasks.add() method:
https://api.daypilot.org/daypilot-gantt-tasks-add/

Answer posted by Bcos
4 years ago.

Thanks , I able to do this on Angular 8 by refer this example
https://code.daypilot.org/29513/angular-scheduler-modal-dialog-for-event-editing

Here shared some testing code

on ts file:

@ViewChild('gantt', { static: false }) gantt: DayPilotGanttComponent;

public createTask(): void{
this.gantt.control.tasks.add(new DayPilot.Task({
id: DayPilot.guid(),
text: 'MO',
start: new DayPilot.Date().getDatePart(),
end: new DayPilot.Date().getDatePart().addDays(1),
type: 'Task'
}));
}

on html file
<daypilot

  • gantt [config]="config" #gantt></daypilot-gantt>
  • <button

(click)="createTask()">Add Task</button>

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.