# Tasks

The right side of the Gantt renders a task element for each expanded data item row in a horizontal timeline view.

> To render the task content and HTML elements in the correct timeline position of the Gantt, the task data items have to either conform to the [`GanttTask`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttask) interface, or you have to provide a [`taskModelFields`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#taskmodelfields) object. For more information, refer to the dedicated article on [binding the Gantt to data](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/data-binding/models#task-model-fields).

## Types

According to the content of the task data item, the Gantt will render the corresponding task element in one of the three following ways:

* `summary` task—Rendered when the task has child subtasks.
* `milestone` task—Rendered when the task has no child subtasks, and the `start` and `end` values are equal.
* `regular` task—Rendered when the task has no child subtasks, and the `start` and `end` values are not equal.

> Whether a task data item has child subtasks is determined through the [`hasChildren`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#haschildren) callback, which is executed with the specified item as its parameter. When you use one of the two data binding directives, this callback gets internally implemented.

The following example demonstrates how the provided content of the task data items is interpreted and rendered.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/types/source.txt)

## Parent-Child Relationships

When working with parent (`summary`) tasks and their subtasks, it's important to maintain proper date relationships:

* The start date of the parent task must be earlier than or equal to the start date of the earliest child task.
* The end date of the parent task must be later than or equal to the end date of the latest child task.

For example, if a parent task runs from `2024-06-02T00:00:00.000Z` to `2024-06-05T00:00:00.000Z`, all child tasks must:

* Start after or on `2024-06-02T00:00:00.000Z`.
* End before or on `2024-06-05T00:00:00.000Z`.

> If a child subtasks's start or end date falls outside the parent task's date range, you must programmatically update the parent task's start and end dates to include the child subtasks's timeline. The Gantt does not automatically adjust parent dates, and an incorrect date hierarchy may lead to unexpected rendering or visual representation.

## Custom Styling

You can style each task element according to the content of its data item by using the [`taskClass`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#taskclass) callback. The callback is executed for every data item and the returned object is supplied to the `ngClass` attribute of the task HTML element.

The following example demonstrates how to apply custom CSS classes to individual Gantt task elements using the `taskClass` callback.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/styling/source.txt)

## Templates

You can customize the content of the task and the summary task components by using the following Gantt templates:

* [`GanttTaskContentTemplateDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskcontenttemplatedirective)—Defines the text content section of the task component.
* [`TaskTemplateDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktemplatedirective)—Defines the whole content for the wrapper element of the task component.
* [`SummaryTaskTemplateDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttsummarytasktemplatedirective)—Defines the whole content of the summary task component.
* [`GanttTaskTooltipTemplateDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktooltiptemplatedirective)—Defines the content of the tooltip that appears when the user hovers over a task.
* [`GanttTaskDragTooltipTemplateDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskdragtooltiptemplatedirective)—Defines the content of the tooltip that appears when the user drags or resizes a task.

### Task Content Template

The following example demonstrates how to customize only the text content section element of the task by using the [`kendoGanttTaskContentTemplate`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskcontenttemplatedirective) directive.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/templates/content/source.txt)

### Task and Summary Task Templates

To customize the entire HTML content of the Gantt tasks and summary tasks, use the [`kendoGanttTaskTemplate`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktemplatedirective) and [`kendoGanttSummaryTaskTemplate`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttsummarytasktemplatedirective) directives.

In the following example, the entire content of the task wrapper element is replaced and the completion ratio overlay element is not rendered. The `elementWidth` context variable retrieves the entire task element width and can be used for a custom completion ratio overlay element composition.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/templates/full-template/source.txt)

### Task Tooltip Template

You can customize the tooltip that appears when the user hovers over a task and include any additional information or change its format.

You can achieve this by using the [`kendoGanttTaskTooltipTemplate`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktooltiptemplatedirective) directive, which allows you to define a custom template for the tooltip content. The template context provides access to the task's `dataItem`, which contains only the properties of the [`GanttTask`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttask) interface.

The following example demonstrates how to customize the tooltip content by using the `dataItem` context variable.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/templates/tooltip-template/source.txt)

### Task Drag Tooltip Template

When you drag or resize tasks in the Gantt timeline, a tooltip appears displaying the updated start and end dates of the task as you perform the drag operation. You can customize the content of this tooltip by using the [`kendoGanttTaskDragTooltipTemplate`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskdragtooltiptemplatedirective) directive.

The template context provides access to the dynamically updated `start` and `end` dates during the drag operation, the `completionRatio` of the task, and the original `task` data item, which contains the properties of the [`GanttTask`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttask) interface.

The following example demonstrates how to customize the drag tooltip to display additional information such as task title, duration and formatted dates.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/tasks/templates/drag-tooltip-template/source.txt)

## Suggested Links

* [API Index of the Gantt](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api)
* [API Reference of the GanttComponent](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent)
* [API Reference of the GanttTaskContentTemplateDirective](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskcontenttemplatedirective)
* [API Reference of the GanttTaskTemplateDirective](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktemplatedirective)
* [API Reference of the GanttSummaryTaskTemplateDirective](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttsummarytasktemplatedirective)
* [API Reference of the GanttTaskTooltipTemplateDirective](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttasktooltiptemplatedirective)
* [API Reference of the GanttTaskDragTooltipTemplateDirective](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/gantttaskdragtooltiptemplatedirective))
