delete-link
Description
Fires when deleting a linkUsage
"delete-link": ({
id: string | number;
}) => boolean|void;
Parameters
The callback of the delete-link action can take an object with the following parameters:
id- (required) the ID of a link to be deleted
info
For handling the actions you can use the Event Bus methods. Returning false from the action handler will block the action (see Preventing actions)
Example
import { getData } from "./common/data";
import { Gantt } from "@svar-ui/react-gantt";
const data = getData();
function init(api) {
api.on("delete-link", ev => {
console.log("The id of the deleted link:", ev.id);
});
}
export default function App() {
return (
<Gantt
tasks={data.tasks}
links={data.links}
init={init}
/>
);
}
Preventing link deletion
You can intercept the action and return false to block it:
// typically inside your init(api) handler:
api.intercept("delete-link", ev => {
if (!allowDelete) return false; // prevents deletion
});
Related articles: