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
    }
});

Dependencies between tasks in the current selected range will also be copied, but not dependencies with tasks outside of that range

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.

Task copy paste
//<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

Common

disabledInstancePlugin
listenersEvents

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Other

copyOnlyCopyPasteBase
cutOnlyRowCopyPaste
dateFormatCopyPasteBase
emptyValueCharCopyPasteBase
generateNewNameCopyPasteBase
keyMapCopyPasteBase
nameFieldRowCopyPaste
toCopyStringCopyPasteBase
toPasteValueCopyPasteBase
useNativeClipboardCopyPasteBase

Properties

19

Common

disabledInstancePlugin

Class hierarchy

isTaskCopyPaste: Boolean= truereadonly
Identifies an object as an instance of TaskCopyPaste class, or subclass thereof.
isTaskCopyPaste: Boolean= truereadonlystatic
Identifies an object as an instance of TaskCopyPaste class, or subclass thereof.
isClipboardableClipboardable
isCopyPasteBaseCopyPasteBase
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable
isRowCopyPasteRowCopyPaste

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

generateNewNameCopyPasteBase

Functions

31

Common

clearClipboardClipboardable
copyRowsRowCopyPaste
pasteRowsRowCopyPaste

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

9

Fires 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 }) => {

});
ParameterTypeDescription
sourceGantt

Owner Gantt

referenceRecordTaskModel

The reference task record, the clipboard task records will be pasted above this row.

recordsTaskModel[]

The records about to be pasted

originalRecordsTaskModel[]

For a copy action, these are the records that were copied. For a cut action, this is same as the records param.

isCutBoolean

true if this is a cut action

entityNameString

'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 }) => {

});
ParameterTypeDescription
sourceGantt

Owner gantt

referenceRecordTaskModel

The reference task record, the clipboard task records will be pasted above this row.

recordsTaskModel[]

The pasted task records

originalRecordsTaskModel[]

For a copy action, these are the records that were copied. For a cut action, this is same as the records param.

isCutBoolean

true if this is a cut action

entityNameString

'task' to distinguish this event from other beforePaste events

beforeCopyRowCopyPaste
catchAllEvents
copyRowCopyPaste
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

9

Called 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 }) {

    }
});
ParameterTypeDescription
sourceGantt

Owner Gantt

referenceRecordTaskModel

The reference task record, the clipboard task records will be pasted above this row.

recordsTaskModel[]

The records about to be pasted

originalRecordsTaskModel[]

For a copy action, these are the records that were copied. For a cut action, this is same as the records param.

isCutBoolean

true if this is a cut action

entityNameString

'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 }) {

    }
});
ParameterTypeDescription
sourceGantt

Owner gantt

referenceRecordTaskModel

The reference task record, the clipboard task records will be pasted above this row.

recordsTaskModel[]

The pasted task records

originalRecordsTaskModel[]

For a copy action, these are the records that were copied. For a cut action, this is same as the records param.

isCutBoolean

true if this is a cut action

entityNameString

'task' to distinguish this event from other beforePaste events

onBeforeCopyRowCopyPaste
onCopyRowCopyPaste
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1