Angular Gantt - tasks
Configures tasks.

Use the dataSource property to bind the UI component to a data source, which contains tasks. If the field names in your data source differ from default names ('id', 'parentId', 'title', 'start', 'end', 'progress', 'color'), use appropriate properties (keyExpr, parentIdExpr, etc.) to map data fields.
- <dx-gantt ... >
- <dxo-tasks
- [dataSource]="tasks"
- keyExpr="taskId"
- parentIdExpr="parentTaskId"
- titleExpr="taskTitle"
- progressExpr="taskProgress"
- startExpr="startDate"
- endExpr="endDate"
- colorExpr="taskColor" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- tasks: Task[];
- // ...
- constructor(service: Service) {
- this.tasks = service.getTasks();
- // ...
- }
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- import { Service, Task, ... } from './app.service';
- @NgModule({
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [Service],
- declarations: [AppComponent],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
- {
- "projects": {
- "ProjectName": {
- "architect": {
- "build": {
- "options": {
- "styles": [
- "node_modules/devextreme/dist/css/dx.light.css",
- "node_modules/devexpress-gantt/dist/dx-gantt.css",
- "src/styles.css"
- ],
- ...
- },
- ...
- },
- ...
- }
- },
- ...
- },
- ...
- }
See Also
colorExpr
Specifies the data field that provides tasks' color.
If the field name in your data source differs from default 'color', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- colorExpr="taskColor" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
dataSource
Binds the UI component to the data source which contains tasks.
Refer to the tasks property to see how to specify the dataSource property.
endExpr
Specifies the data field that provides tasks' end dates.
If the field name in your data source differs from default 'end', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- endExpr="endDate" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
keyExpr
Specifies the data field that provides keys for tasks.
If the field name in your data source differs from default 'id', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- keyExpr="taskId" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
parentIdExpr
Specifies the data field that provides tasks' parent IDs.
If the field name in your data source differs from default 'parentId', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- parentIdExpr="parentTaskId" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
progressExpr
Specifies the data field that provides tasks' progress.
If the field name in your data source differs from default 'progress', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- progressExpr="taskProgress" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
startExpr
Specifies the data field that provides tasks' start dates.
If the field name in your data source differs from default 'start', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- startExpr="startDate" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }
titleExpr
Specifies the data field that provides task titles.
If the field name in your data source differs from default 'title', use this property to map data fields:
- <dx-gantt ... >
- <dxo-tasks ...
- [dataSource]="tasks"
- titleExpr="taskTitle" >
- </dxo-tasks>
- <!-- ... -->
- </dx-gantt>
- import { Injectable } from '@angular/core';
- export class Task {
- taskId: number;
- parentTaskId: number;
- taskTitle: string;
- startDate: Date;
- endDate: Date;
- taskProgress: number;
- taskColor: string;
- }
- const tasks: Task[] = [{
- 'taskId': 1,
- 'parentTaskId': 0,
- 'taskTitle': 'Software Development',
- 'startDate': new Date('2019-02-21T05:00:00.000Z'),
- 'endDate': new Date('2019-07-04T12:00:00.000Z'),
- 'taskProgress': 31,
- 'taskColor': 'red'
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getTasks(): Task[] {
- return tasks;
- }
- }