copy-task
Description
Fires when copying a taskUsage
"copy-task": ({
id: string | number,
target?: string | number,
eventSource?: string,
mode?: string,
source?: string | number,
lazy?: boolean,
}) => boolean|void;
Parameters
The callback of the copy-task action can take an object with the following parameters:
id
- (required) the ID of a newly copied tasktarget
- (optional) the task ID before or after which a new task will be copied tosource
- (optional) the ID of a task that is copiedeventSource
- (optional) the name of an action that triggered the "copy-task" actionmode
- (optional) specifies where to place a task: before - before the task which id is specified or after it (after)lazy
- (optional) the parameter indicates if it's necessary to copy nested tasks on the backend; if a task that is copied is marked as "lazy" (see the lazy parameter in thetasks
property) and it has nested tasks that are not yet loaded from the backend, the value is set to true, which means that tasks should be copied on the backend; if there are nested tasks in the client data, the parameter is set to false, which means that tasks will be copied on the client by sending its "copy-task" actions
info
For handling the actions you can use the Event Bus methods
Example
import { useEffect, useRef } from "react";
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
const MyGanttComponent = () => {
const data = getData();
const apiRef = useRef(null);
useEffect(() => {
if (apiRef.current) {
apiRef.current.on("copy-task", (ev) => {
console.log("The id of the copied task:", ev.id);
});
}
}, [apiRef.current]);
return (
<Gantt
ref={apiRef}
tasks={data.tasks}
//other settings
/>
);
};
export default MyGanttComponent;
Related articles: How to access Gantt API