JavaScript/jQuery Gantt Options

An object that defines the Gantt widget's configuration options.

See Also

accessKey

Specifies the shortcut key that sets focus on the widget.

Type:

String

Default Value: null

The value of this option will be passed to the accesskey attribute of the HTML element that underlies the widget.

activeStateEnabled

Specifies whether or not the widget changes its state when interacting with a user.

Type:

Boolean

Default Value: false

This option is used when the widget is displayed on a platform whose guidelines include the active state change for widgets.

allowSelection

Specifies whether users can select tasks in the Gantt.

Type:

Boolean

Default Value: true

View Demo

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • allowSelection: false,
  • // ...
  • });
  • });
See Also

columns

An array of columns in the Gantt.

Default Value: undefined

The columns option accepts an array of columns. To configure a column, use a dxTreeListColumn object or specify a data source field (as a string value) to which the column is bound.

View Demo

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • columns: [{
  • dataField: "title",
  • caption: "Subject",
  • width: 300
  • }, {
  • dataField: "start",
  • caption: "Start Date"
  • }, "end"
  • ],
  • // ...
  • });
  • });

dependencies

Configures dependencies.

Type:

Object

Default Value: null

View Demo

Dependencies specify the relationships between tasks. The following image illustrates how the Gantt displays dependencies in the chart:

DevExtreme Gantt Chart - Dependencies

The Gantt widget supports the following dependency types:

  • Finish to Start (FS) - The predecessor task's endpoint specifies the successor task's start point.

  • Start to Start (SS) - The predecessor task's start point specifies the successor task's start point.

  • Finish to Finish (FF) - The predecessor task's end point specifies the successor task's end point.

  • Start to Finish (SF) - The predecessor task's start point specifies the successor task's end point.

Use the dataSource option to bind the widget to a data source, which contains information about dependency types. If the field names in your data source differ from the 'id', 'type', 'predecessorId' and 'successorId' default names, use the keyExpr, typeExpr options to map data fields.

See Also
index.js
data.js
  • $(function() {
  • $("#gantt").dxGantt({
  • dependencies: {
  • dataSource: dependencies,
  • keyExpr: "dependencyId",
  • typeExpr: "dependencyType",
  • predecessorIdExpr: "taskPredecessorId",
  • successorIdExpr: "taskSuccessorId"
  • },
  • //...
  • });
  • });
  • var dependencies = [{
  • 'dependencyId': 0,
  • 'taskPredecessorId': 1,
  • 'taskSuccessorId': 2,
  • 'dependencyType': 0
  • },
  • // ...
  • ];

disabled

Specifies whether the widget responds to user interaction.

Type:

Boolean

Default Value: false

editing

Configures edit options.

Type:

Object

The widget allows users to add, modify and delete tasks, resources and dependencies. Set the enabled option to true to enable edit functionality.

NOTE
Make sure that your data sources (tasks, resources and dependencies) support edit actions.

View Demo

index.js
  • $(function() {
  • $("#gantt").dxGantt({
  • editing: {
  • //...
  • }
  • });
  • });

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type:

Object

Default Value: {}

  • $(function(){
  • $("#ganttContainer").dxGantt({
  • // ...
  • elementAttr: {
  • id: "elementId",
  • class: "class-name"
  • }
  • });
  • });

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

Type:

Boolean

Default Value: false

height

Specifies the widget's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's height.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The height in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "80%", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    • height: function() {
    • return window.innerHeight / 1.5;
    • }

hint

Specifies text for a hint that appears when a user pauses on the widget.

Type:

String

Default Value: undefined

hoverStateEnabled

Specifies whether the widget changes its state when a user pauses on it.

Type:

Boolean

Default Value: false

onContentReady

A function that is executed when the widget's content is ready and each time the content is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Gantt

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

Model data. Available only when using Knockout.

Default Value: null

onDisposing

A function that is executed before the widget is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Gantt

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

Model data. Available only if you use Knockout.

Default Value: null

onInitialized

A function used in JavaScript frameworks to save the widget instance.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Gantt

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

Default Value: null

See Also

onOptionChanged

A function that is executed after a widget option is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
model

Object

Model data. Available only if you use Knockout.

fullName

String

The path to the modified option that includes all parent options.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Gantt

The widget's instance.

name

String

The modified option if it belongs to the first level. Otherwise, the first-level option it is nested into.

value any

The modified option's new value.

Default Value: null

onSelectionChanged

A function that is executed after users select a task or clear its selection.

Type:

Function

Function parameters:
e:

Object

Information about the event that caused the function's execution.

Object structure:
Name Type Description
component

Gantt

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

Model data. Available only if you use Knockout.

selectedRowKey any

The key of the row whose selection state was changed.

Default Value: null

View Demo

index.js
  • $(function() {
  • $("#gantt").dxGantt({
  • // ...
  • onSelectionChanged: function (e) {
  • if (e.selectedRowKey === 2) {
  • // your code
  • } else {
  • // your code
  • }
  • }
  • });
  • });
See Also

resourceAssignments

Configures resource assignments.

Type:

Object

Default Value: null

View Demo

Resource assignments define relationship between tasks and resources.

Use the dataSource option to bind the widget to a data source, which contains resource assignments. If the field names in your data source differ from the 'id', 'resourceId' and 'taskId' default names, use the keyExpr, resourceIdExpr and/or taskIdExpr options to map data fields.

See Also
index.js
data.js
  • $(function() {
  • $("#gantt").dxGantt({
  • resourceAssignments: {
  • dataSource: resourceAssignments,
  • keyExpr: "key",
  • resourceIdExpr: "resourceKey",
  • taskIdExpr: "taskKey"
  • },
  • //...
  • });
  • });
  • var resourceAssignments = [{
  • 'key': 0,
  • 'taskKey': 3,
  • 'resourceKey': 1
  • },
  • // ...
  • ];

resources

Configures task resources.

Type:

Object

Default Value: null

View Demo

You can add resources to a project and assign them to tasks. Resources can be people responsible for tasks, equipment, materials, etc. The Gantt displays resources as labels on the right of the tasks.

DevExtreme Gantt Chart - Resources

Use the dataSource option to bind the widget to a data source, which contains resources. If the field names in your data source differ from the 'id' and 'text' default names, use the keyExpr and/or textExpr options to map data fields.

See Also
index.js
data.js
  • $(function() {
  • $("#gantt").dxGantt({
  • resources: {
  • dataSource: resources,
  • keyExpr: "resourceId",
  • textExpr: "title"
  • },
  • //...
  • });
  • });
  • var resources = [{
  • 'resourceId': 1,
  • 'title': 'Management'
  • },
  • // ...
  • ];

scaleType

Specifies the zoom level of tasks in the Gantt chart.

Type:

String

Default Value: 'auto'
Accepted Values: 'auto' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years'

The scaleType option specifies the zoom level for tasks when the Gantt widget is initialized or when you call the option() method.

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • scaleType: 'hours',
  • // ...
  • });
  • });

If the scaleType option is set to "auto", the widget is scaled to fit all tasks in the Gantt chart's visible area.

To browse tasks across various levels of detail in real time, hold the CTRL key and scroll the mouse wheel to zoom (in or out).

selectedRowKey

Allows you to select a row or determine which row is selected.

Type: any
Default Value: undefined

View Demo

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • selectedRowKey: 1,
  • // ...
  • });
  • });
See Also

showResources

Specifies whether to display task resources.

Type:

Boolean

Default Value: true

View Demo

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • showResources: false,
  • // ...
  • });
  • });

showRowLines

Specifies whether to show/hide horizontal faint lines that separate tasks.

Type:

Boolean

Default Value: true

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • showRowLines: false,
  • // ...
  • });
  • });

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

Type:

Number

Default Value: 0

The value of this option will be passed to the tabindex attribute of the HTML element that underlies the widget.

taskListWidth

Specifies the width of the task list in pixels.

Type:

Number

Default Value: 300

View Demo

DevExtreme Gantt Chart - Task List

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • taskListWidth: 200,
  • // ...
  • });
  • });

tasks

Configures tasks.

Type:

Object

Default Value: null

View Demo

DevExtreme Gantt Chart - Tasks

Use the dataSource option to bind the widget 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'), use appropriate options (keyExpr, parentIdExpr, etc.) to map data fields.

See Also
index.js
data.js
  • $(function() {
  • $("#gantt").dxGantt({
  • tasks: {
  • dataSource: tasks,
  • keyExpr: "taskId",
  • parentIdExpr: "parentTaskId",
  • titleExpr: "taskTitle",
  • progressExpr: "taskProgress",
  • startExpr: "startDate",
  • endExpr: "endDate"
  • },
  • //...
  • });
  • });
  • var tasks = [{
  • '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
  • },
  • // ...
  • ];

taskTitlePosition

Specifies a task's title position.

Type:

String

Default Value: 'inside'
Accepted Values: 'inside' | 'outside' | 'none'

Titles can be displayed "inside" or "outside" the the task. Set the position to "none" to hide the title.

DevExtreme Gantt Chart - Task titles

JavaScript
  • $(function() {
  • $("#gantt").dxGantt({
  • taskTitlePosition: 'none',
  • // ...
  • });
  • });

visible

Specifies whether the widget is visible.

Type:

Boolean

Default Value: true

width

Specifies the widget's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's width.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The width in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    • width: function() {
    • return window.innerWidth / 1.5;
    • }