Skip to main content

delete-task

Description

Fires when deleting a task

Usage

"delete-task": ({
id: string | number,
source?: string | number
}) => boolean|void;

Parameters

The callback of the delete-task action can take an object with the following parameters:

  • id - (required) the ID of a task to be deleted
  • source - (optional) the ID of a source task that is deleted
info

For handling the actions you can use the Event Bus methods

Example

Use the api.exec method to trigger the action:

import { useRef, useState } from "react";
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
import "wx-react-gantt/dist/gantt.css";
import { Button } from "wx-react-wx";

function App() {
const data = getData();
const apiRef = useRef();
const [selected, setSelected] = useState();

function handleDelete() {
apiRef.current.exec("delete-task", { id: selected });
}

return (
<>
<Toolbar>
{selected && <Button onClick={handleDelete}>Delete task</Button>}
</Toolbar>
<Gantt
ref={apiRef}
tasks={data.tasks}
//other settings
/>
</>
);
}

export default App;

Related articles: How to access Gantt API