Skip to main content

api.exec()

Description​

Allows triggering Gantt actions

Usage​

api.exec(
action: string,
config: object
): void;

Parameters​

  • action - (required) an action to be fired
  • config - (required) the config object with parameters (see the action to be fired)

Actions​

info

The full list of the Gantt actions can be found here

Example​

The example below shows how to clear the task text when opening the Editor dialog for it.

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

const data = getData();

export default function Example() {
const apiRef = useRef(null);

function clearTaskText() {
apiRef.current?.exec("update-task", { id: 3, task: { text: "" } });
}

return (
<Gantt tasks={data.tasks} onShowEditor={clearTaskText} ref={apiRef} />
);
}

Related articles: