AllocationCopyPaste
This is a feature of ResourceUtilization view that allows to copy-paste assignment time-phased effort values.
// <code-header>
fiddle.title = 'Allocation copy paste';
// This example uses Scheduler Pro TimePhasedProjectModel class
// which is named SchedulerProTimePhasedProjectModel in the Gantt distribution
TimePhasedProjectModel = typeof SchedulerProTimePhasedProjectModel !== 'undefined' ? SchedulerProTimePhasedProjectModel : TimePhasedProjectModel;
targetElement.innerHTML = '<p>Select an event effort value then use <kbd>CTRL</kbd> + <kbd>C</kbd> to copy it and then use <kbd>CTRL</kbd> + <kbd>V</kbd> to paste it to another selected location:</p>';
// </code-header>
const resourceUtilization = new ResourceUtilization({
project : new TimePhasedProjectModel({
loadUrl : 'data/SchedulerPro/examples/view/ResourceUtilization2.json',
autoLoad : true,
validateResponse : false
}),
columns : [
{
type : 'tree',
text : 'Name',
field : 'name',
width : 150,
renderer({ record, value }) {
return record.generatedParent ? record.key.name : value;
}
}
],
// the view is not readOnly to allow pasting
readOnly : false,
features : {
// Allow effort values copy/pasting
allocationCopyPaste : true,
allocationCellEdit : true,
scheduleContext : {
// allow navigating the time axis cells w/ keyboard
keyNavigation : true,
// allow multi selecting the time axis cells
// (can be useful for copy/pasting values there)
multiSelect : true
},
treeGroup : {
// group by resource
levels : [
// group by resource
({ origin }) => {
// origin could be an array of time-phased assignments
origin = origin[0] || origin;
return origin.resource;
}
]
}
},
startDate : new Date(2020, 3, 26),
endDate : new Date(2020, 4, 15),
appendTo : targetElement,
rowHeight : 40,
tickSize : 40,
minHeight : '21em',
// display tooltip
showBarTip : true
});new ResourceUtilization({
...
// the view should not be readOnly to allow pasting
readOnly : false,
features : {
// allow effort copy-pasting
allocationCopyPaste : true,
...
},
...
});
This feature is disabled by default.
Configs
18
Configs
18Other
Provide true to accept pasting in an event timespan only.
Misc
Properties
18
Properties
18Common
Class hierarchy
Functions
32
Functions
32Common
Other
Copies selected cells to clipboard (native if accessible) to paste later
Cuts selected cells to clipboard (native if accessible) to paste later
Pastes string data into a cell or a range of cells. Either from native clipboard if that is accessible or from a fallback clipboard that is only available to the owner view.
The string data will be split on \n and \t and put in different rows and columns accordingly.
Note that there must be a selected cell to paste the data into.
Configuration
Events
Misc
Events
9
Events
9Fires on the owning view before a copy action is performed, return false to prevent the action
// Adding a listener using the "on" method
allocationCopyPaste.on('beforeCopyTimelineCells', ({ source, cells, data, isCut }) => {
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
cells | TimelineContext[] | The cells about to be copied or cut |
data | String | The string data about to be copied or cut |
isCut | Boolean |
|
Fires on the owning Grid before a paste action is performed, return false to prevent the action
// Adding a listener using the "on" method
allocationCopyPaste.on('beforePasteTimelineCells', ({ source, clipboardData, targetCell }) => {
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
clipboardData | String | The clipboardData about to be pasted |
targetCell | TimelineContext | The cell from which the paste will be started |
Fires on the owning view after a copy action is performed.
// Adding a listener using the "on" method
allocationCopyPaste.on('copyTimelineCells', ({ source, cells, copiedDataString, isCut }) => {
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
cells | TimelineContext[] | The cells about to be copied or cut |
copiedDataString | String | The concatenated data string that was copied or cut |
isCut | Boolean |
|
Fires on the owning view after a paste action is performed.
// Adding a listener using the "on" method
allocationCopyPaste.on('pasteTimelineCells', ({ source, clipboardData, modifiedRecords, targetCell }) => {
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
clipboardData | String | The clipboardData that was pasted |
modifiedRecords | Model[] | The records which have been modified due to the paste action |
targetCell | TimelineContext | The cell from which the paste will be started |
Event handlers
9
Event handlers
9Called on the owning view before a copy action is performed, return false to prevent the action
new AllocationCopyPaste({
onBeforeCopyTimelineCells({ source, cells, data, isCut }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
cells | TimelineContext[] | The cells about to be copied or cut |
data | String | The string data about to be copied or cut |
isCut | Boolean |
|
Called on the owning Grid before a paste action is performed, return false to prevent the action
new AllocationCopyPaste({
onBeforePasteTimelineCells({ source, clipboardData, targetCell }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
clipboardData | String | The clipboardData about to be pasted |
targetCell | TimelineContext | The cell from which the paste will be started |
Called on the owning view after a copy action is performed.
new AllocationCopyPaste({
onCopyTimelineCells({ source, cells, copiedDataString, isCut }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
cells | TimelineContext[] | The cells about to be copied or cut |
copiedDataString | String | The concatenated data string that was copied or cut |
isCut | Boolean |
|
Called on the owning view after a paste action is performed.
new AllocationCopyPaste({
onPasteTimelineCells({ source, clipboardData, modifiedRecords, targetCell }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | ResourceUtilization | Owner view |
clipboardData | String | The clipboardData that was pasted |
modifiedRecords | Model[] | The records which have been modified due to the paste action |
targetCell | TimelineContext | The cell from which the paste will be started |