Skip to main content

update-link

Description​

Fires when updating a link

Usage​

"update-link": ({
id: string | number,
link: Partial<ILink>
}) => boolean | void;

Parameters​

The callback of the update-link action can take an object with the following parameters:

  • id - (required) the id of a link
  • link - (required) the link object with the fields to be updated
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​

In the example below we apply the api.exec method to trigger the action with a button click:

import { useRef } from "react";
import { getData } from "./common/data";
import { Gantt } from "@svar-ui/react-gantt";
import { Button } from "@svar-ui/react-core";

function App() {
const data = getData();
const api = useRef(null);

const updateLink = () => {
api.current.exec("update-link", {
id: 1,
link: { type: "s2s" }
});
};

return (
<>
<Button onClick={updateLink} type="primary">Update Link</Button>

<Gantt
tasks={data.tasks}
links={data.links}
ref={api} />
</>
);
}

export default App;

Related articles: