Angular/Auto scheduling
Loading live demo…from dhtmlx.github.io
Angular
Auto scheduling
Recalculate dependent tasks and links when schedule changes should cascade through a project.
- auto-scheduling.ts
- auto-scheduling.html
- auto-scheduling.css
src/app/samples/auto-scheduling/auto-scheduling.ts View on GitHub
import { Component, ViewChild, ViewEncapsulation } from '@angular/core';
import { DemoToolbarComponent } from '../../shared/demo-toolbar/demo-toolbar';
import { createBasicDemoData } from '../../shared/demo-data';
import { DhxGanttComponent, type AngularGanttDataConfig } from '@dhtmlx/trial-angular-gantt';
@Component({
selector: 'app-auto-scheduling',
standalone: true,
imports: [DemoToolbarComponent, DhxGanttComponent],
templateUrl: './auto-scheduling.html',
styleUrl: './auto-scheduling.css',
encapsulation: ViewEncapsulation.None
})
export class AutoSchedulingComponent {
private readonly initial = createBasicDemoData();
tasks = this.initial.tasks;
links = this.initial.links;
@ViewChild(DhxGanttComponent) ganttCmp?: DhxGanttComponent;
plugins = { auto_scheduling: true };
config = {
auto_scheduling: {
enabled: true,
apply_constraints: false,
gap_behavior: "compress" as const
},
columns: [
{ name: "text", label: "Task", tree: true, width: "*" },
{ name: "start_date", label: "Start", align: "center" },
{ name: "duration", label: "Duration", align: "center" },
{ name: "add", width: 44 },
],
date_format: "%Y-%m-%d %H:%i",
};
dataConfig: AngularGanttDataConfig = {
batchSave: (changes) => {
console.log('[data.batchSave]', changes);
},
};
runAutoSchedule() {
const gantt = this.ganttCmp?.instance;
if (!gantt) return;
gantt.autoSchedule();
}
}
src/app/samples/auto-scheduling/auto-scheduling.html View on GitHub
<div class="card">
<dhx-demo-toolbar title="Auto Scheduling">
<button (click)="runAutoSchedule()">Run Auto Scheduling</button>
</dhx-demo-toolbar>
<div class="gantt-host">
<dhx-gantt [tasks]="tasks" [links]="links" [config]="config" [plugins]="plugins"
[data]="dataConfig">
</dhx-gantt>
</div>
<div class="note">
Verifies plugin enablement + calling underlying API via <code>ViewChild</code>.
</div>
</div>
src/app/samples/auto-scheduling/auto-scheduling.css View on GitHub
@import "@dhtmlx/trial-angular-gantt/dist/angular-gantt.css";
.dhx-gantt-root {
height: 100%;
width: 100%;
}