Skip to main content

update-link

Description

Fires when updating a link

Usage

"update-link": ({
id: string | number,
link: any
}) => 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) an object with the link data:
    • source - (required) the source task ID
    • target - (required) the target task ID
    • type - (required) the link type; possible link type values:
       - 0 - "End-to-start" 
      - 1 - "Start-to-start"
      - 2 - "End-to-end"
      - 3 - "Start-to-end"
info

For handling the actions you can use the Event Bus methods

Example

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

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

const App = () => {
const data = getData();
const apiRef = useRef();

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

return (
<>
<Button onClick={updateLink} type="primary">Update Link</Button>
<Gantt
ref={apiRef}
tasks={data.tasks}
links={data.links}
// other settings
/>
</>
);
};

export default App;

Related articles: How to access Gantt API