TaskResize
Feature that allows resizing a task by dragging its end date. Resizing a task by dragging its start date is not allowed.
This feature is enabled by default
This feature updates the event's endDate live in order to leverage the
rendering pathway to always yield a correct appearance. The changes are done in
batched mode so that changes do not become
eligible for data synchronization or propagation until the operation is completed.
Customizing the resize tooltip
To show custom HTML in the tooltip, please see the tooltipTemplate config. Example:
taskResize : {
// A minimal end date tooltip
tooltipTemplate : ({ record, endDate }) => {
return DateHelper.format(endDate, 'MMM D');
}
}
Configs
27
Configs
27Other
Set to true to enable resizing task while pinning dependent tasks. By default, this behavior is activated
if you hold CTRL key during drag. Alternatively, you may provide key name to use. Supported values are:
- 'ctrl'
- 'shift'
- 'alt'
- 'meta'
Note: Only supported in forward-scheduled project
Misc
Properties
19
Properties
19Common
Class hierarchy
Other
Gets or sets special key to activate successor pinning behavior. Supported values are:
- 'ctrl'
- 'shift'
- 'alt'
- 'meta'
Assign false to disable it.
Functions
28
Functions
28Configuration
Events
Misc
Other
Events
15
Events
15Fires on the owning Gantt before resizing starts. Return false to prevent the operation.
// Adding a listener using the "on" method
taskResize.on('beforeTaskResize', ({ taskRecord, event }) => {
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
event | Event |
Fires on the owning Gantt to allow implementer to prevent immediate finalization by setting
data.context.async = true in the listener, to show a confirmation popup etc.
gantt.on('beforeTaskResizeFinalize', ({context}) => {
context.async = true;
setTimeout(() => {
// async code don't forget to call finalize
context.finalize();
}, 1000);
})
// Adding a listener using the "on" method
taskResize.on('beforeTaskResizeFinalize', ({ taskRecord, source, context, context.endDate, context.originalEndDate, context.resizeData, event, context.async, context.finalize }) => {
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
source | Gantt | Gantt instance |
context | Object | |
context.endDate | Date | New endDate |
context.originalEndDate | Date | End date before resize |
context.resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
event | Event | Browser event |
context.async | Boolean | Set true to handle resize asynchronously (e.g. to wait for user confirmation) |
context.finalize | function | Call this method to finalize resize. This method accepts one argument: pass true to update records, or false, to ignore changes |
Fires on the owning Gantt on each resize move event
// Adding a listener using the "on" method
taskResize.on('taskPartialResize', ({ resizeData, taskRecord, startDate, endDate, element }) => {
});| Parameter | Type | Description |
|---|---|---|
resizeData | TaskResizeData[] | Data for the tasks that are being resized. Only available when
resizeSelected is |
taskRecord | TaskModel | Task record being resized |
startDate | Date | New startDate |
endDate | Date | New endDate |
element | HTMLElement |
Fires on the owning Gantt after the resizing gesture has finished.
// Adding a listener using the "on" method
taskResize.on('taskResizeEnd', ({ changed, taskRecord, resizeData }) => {
});| Parameter | Type | Description |
|---|---|---|
changed | Boolean | |
taskRecord | TaskModel | |
resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
Fires on the owning Gantt when task resizing starts
// Adding a listener using the "on" method
taskResize.on('taskResizeStart', ({ taskRecord, event, resizeData }) => {
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
event | Event | |
resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
Event handlers
15
Event handlers
15Called on the owning Gantt before resizing starts. Return false to prevent the operation.
new TaskResize({
onBeforeTaskResize({ taskRecord, event }) {
}
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
event | Event |
Called on the owning Gantt to allow implementer to prevent immediate finalization by setting
data.context.async = true in the listener, to show a confirmation popup etc.
gantt.on('beforeTaskResizeFinalize', ({context}) => {
context.async = true;
setTimeout(() => {
// async code don't forget to call finalize
context.finalize();
}, 1000);
})
new TaskResize({
onBeforeTaskResizeFinalize({ taskRecord, source, context, event }) {
}
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
source | Gantt | Gantt instance |
context | Object | |
context.endDate | Date | New endDate |
context.originalEndDate | Date | End date before resize |
context.resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
event | Event | Browser event |
context.async | Boolean | Set true to handle resize asynchronously (e.g. to wait for user confirmation) |
context.finalize | function | Call this method to finalize resize. This method accepts one argument: pass true to update records, or false, to ignore changes |
Called on the owning Gantt on each resize move event
new TaskResize({
onTaskPartialResize({ resizeData, taskRecord, startDate, endDate, element }) {
}
});| Parameter | Type | Description |
|---|---|---|
resizeData | TaskResizeData[] | Data for the tasks that are being resized. Only available when
resizeSelected is |
taskRecord | TaskModel | Task record being resized |
startDate | Date | New startDate |
endDate | Date | New endDate |
element | HTMLElement |
Called on the owning Gantt after the resizing gesture has finished.
new TaskResize({
onTaskResizeEnd({ changed, taskRecord, resizeData }) {
}
});| Parameter | Type | Description |
|---|---|---|
changed | Boolean | |
taskRecord | TaskModel | |
resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
Called on the owning Gantt when task resizing starts
new TaskResize({
onTaskResizeStart({ taskRecord, event, resizeData }) {
}
});| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | |
event | Event | |
resizeData | TaskResizeData[] | Resize data for selected tasks. Only available when
resizeSelected is |
Typedefs
3
Typedefs
3An object containing data related to task resize.
| Parameter | Type | Description |
|---|---|---|
taskRecord | TaskModel | Task record being resized |
startDate | Date | New startDate (changed if resizing start side) |
endDate | Date | New endDate (changed if resizing end side) |
originalStartDate | Date | Start date before resize |
originalEndDate | Date | End date before resize |
element | HTMLElement | The task element |