TaskSegmentResize
Feature that allows resizing a task segment by dragging its end.
//<code-header>
fiddle.title = 'Task segments';
//</code-header>
const gantt = new Gantt({
appendTo : targetElement,
height : 200,
startDate : '2022-07-25',
endDate : '2022-08-01',
rowHeight : 60,
project : new ProjectModel({
startDate : '2022-07-25',
events : [
{
id : 1,
name : 'Task A',
startDate : '2022-07-25',
duration : 3,
segments : [
{
startDate : '2022-07-25',
duration : 2
},
{
startDate : '2022-07-28',
duration : 1
}
]
},
{
id : 2,
name : 'Task B',
startDate : '2022-07-25',
duration : 3,
segments : [
{
startDate : '2022-07-25',
duration : 1
},
{
startDate : '2022-07-27',
duration : 2
},
{
startDate : '2022-07-30',
duration : 1
}
]
}
]
})
});This feature is enabled by default.
Configs
26
Configs
26Misc
Other
Properties
19
Properties
19Common
Class hierarchy
Functions
28
Functions
28Configuration
Events
Misc
Other
Events
20
Events
20Fired on the owning Gantt before resizing starts. Return false to prevent the action.
// Adding a listener using the "on" method
taskSegmentResize.on('beforeTaskSegmentResize', ({ source, taskRecord, resourceRecord, event }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser event |
Fired 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('beforeTaskSegmentResizeFinalize', ({context}) => {
context.async = true;
setTimeout(() => {
// async code don't forget to call finalize
context.finalize();
}, 1000);
})
// Adding a listener using the "on" method
taskSegmentResize.on('beforeTaskSegmentResizeFinalize', ({ source, context, context.async, context.finalize }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
context | Object | |
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 |
Fires on the owning Gantt on each resize move event
// Adding a listener using the "on" method
taskSegmentResize.on('taskSegmentPartialResize', ({ source, taskRecord, startDate, endDate, element }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
startDate | Date | |
endDate | Date | |
element | HTMLElement |
Fires on the owning Gantt after the resizing gesture has finished.
// Adding a listener using the "on" method
taskSegmentResize.on('taskSegmentResizeEnd', ({ source, changed, taskRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
changed | Boolean | Shows if the record has been changed by the resize action |
taskRecord | TaskModel | Segment being resized |
Fires on the owning Gantt when event resizing starts
// Adding a listener using the "on" method
taskSegmentResize.on('taskSegmentResizeStart', ({ source, taskRecord, resourceRecord, event }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser event |
Event handlers
20
Event handlers
20Called on the owning Gantt before resizing starts. Return false to prevent the action.
new TaskSegmentResize({
onBeforeTaskSegmentResize({ source, taskRecord, resourceRecord, event }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser 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('beforeTaskSegmentResizeFinalize', ({context}) => {
context.async = true;
setTimeout(() => {
// async code don't forget to call finalize
context.finalize();
}, 1000);
})
new TaskSegmentResize({
onBeforeTaskSegmentResizeFinalize({ source, context }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
context | Object | |
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 |
Called on the owning Gantt on each resize move event
new TaskSegmentResize({
onTaskSegmentPartialResize({ source, taskRecord, startDate, endDate, element }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
startDate | Date | |
endDate | Date | |
element | HTMLElement |
Called on the owning Gantt after the resizing gesture has finished.
new TaskSegmentResize({
onTaskSegmentResizeEnd({ source, changed, taskRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
changed | Boolean | Shows if the record has been changed by the resize action |
taskRecord | TaskModel | Segment being resized |
Called on the owning Gantt when event resizing starts
new TaskSegmentResize({
onTaskSegmentResizeStart({ source, taskRecord, resourceRecord, event }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Gantt instance |
taskRecord | TaskModel | Segment being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser event |