TaskCopyPaste
Allow using Ctrl/CMD + C/X and Ctrl/CMD + V to copy/cut and paste tasks. You can configure how a newly pasted record is named using generateNewName
This feature is enabled by default
const gantt = new Gantt({
features : {
taskCopyPaste : true
}
});
Keyboard shortcuts
By default, this feature will react to Ctrl + C, Ctrl + X and Ctrl + V for standard clipboard actions. You can reconfigure the keys used to trigger these actions, see keyMap for more details.
//<code-header>
fiddle.title = 'Task copy paste';
//</code-header>
targetElement.innerHTML = '<p>Copy/cut and paste rows using keyboard shortcuts or context menu:</p>';
// Gantt with basic configuration
const gantt = new Gantt({
appendTo : targetElement,
// makes Gantt as high as it needs to be to fit rows
autoHeight : true,
columns : [
{ type : 'name', field : 'name', text : 'Name' }
],
startDate : new Date(2021, 1, 4),
endDate : new Date(2021, 1, 11),
tasks : [
{
id : 1,
name : 'Project A',
startDate : '2021-02-04',
duration : 5,
expanded : true,
children : [
{
id : 11,
name : 'Preparation work A',
startDate : '2021-02-04',
percentDone : 50,
duration : 2
},
{
id : 111,
name : 'Start work A',
startDate : '2021-02-06',
duration : 2
}
]
},
{
id : 2,
name : 'Project B',
startDate : '2021-02-06',
duration : 5,
expanded : true,
children : [
{
id : 22,
name : 'Preparation work B',
startDate : '2021-02-06',
percentDone : 50,
duration : 2
},
{
id : 222,
name : 'Start work B',
startDate : '2021-02-08',
duration : 2
}
]
}
]
});Configs
20
Configs
20Misc
Other
Properties
19
Properties
19Common
Class hierarchy
Functions
31
Functions
31Configuration
Events
Misc
Other
Events
9
Events
9Fires on the owning Gantt before a paste action is performed, return false to prevent the action
// Adding a listener using the "on" method
taskCopyPaste.on('beforePaste', ({ source, referenceRecord, records, originalRecords, isCut, entityName }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Owner Gantt |
referenceRecord | TaskModel | The reference task record, the clipboard task records will be pasted above this row. |
records | TaskModel[] | The records about to be pasted |
originalRecords | TaskModel[] | For a copy action, these are the records that were copied. For a
cut action, this is same as the |
isCut | Boolean |
|
entityName | String | 'task' to distinguish this event from other beforePaste events |
Fires on the owning Gantt after a paste action is performed.
// Adding a listener using the "on" method
taskCopyPaste.on('paste', ({ source, referenceRecord, records, originalRecords, isCut, entityName }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Owner gantt |
referenceRecord | TaskModel | The reference task record, the clipboard task records will be pasted above this row. |
records | TaskModel[] | The pasted task records |
originalRecords | TaskModel[] | For a copy action, these are the records that were copied. For a
cut action, this is same as the |
isCut | Boolean |
|
entityName | String | 'task' to distinguish this event from other beforePaste events |
Event handlers
9
Event handlers
9Called on the owning Gantt before a paste action is performed, return false to prevent the action
new TaskCopyPaste({
onBeforePaste({ source, referenceRecord, records, originalRecords, isCut, entityName }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Owner Gantt |
referenceRecord | TaskModel | The reference task record, the clipboard task records will be pasted above this row. |
records | TaskModel[] | The records about to be pasted |
originalRecords | TaskModel[] | For a copy action, these are the records that were copied. For a
cut action, this is same as the |
isCut | Boolean |
|
entityName | String | 'task' to distinguish this event from other beforePaste events |
Called on the owning Gantt after a paste action is performed.
new TaskCopyPaste({
onPaste({ source, referenceRecord, records, originalRecords, isCut, entityName }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Gantt | Owner gantt |
referenceRecord | TaskModel | The reference task record, the clipboard task records will be pasted above this row. |
records | TaskModel[] | The pasted task records |
originalRecords | TaskModel[] | For a copy action, these are the records that were copied. For a
cut action, this is same as the |
isCut | Boolean |
|
entityName | String | 'task' to distinguish this event from other beforePaste events |