Skip to main content

open-task

Description

Fires when expanding a branch of tasks

Usage

"open-task": ({ 
id: string | number,
mode: boolean
}) => boolean|void;

Parameters

The callback of the action takes an object with the following parameters:

  • id - (required) the ID of a task
  • mode - (required) defines whether a branch of tasks is opened (true) or closed (false); it's closed by default
info

For handling the actions you can use the Event Bus methods

Example

import React, { useEffect, useRef } from "react";
import { getData } from "../data";
import { Gantt } from "wx-react-gantt";
import "wx-react-gantt/dist/gantt.css";

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

useEffect(() => {
if (apiRef.current) {
apiRef.current.exec("open-task", {
id: 3,
mode: true,
});
}
}, [apiRef.current]);

return (
<Gantt
api={apiRef}
tasks={data.tasks}
links={data.links}
// other settings
/>
);
};

export default MyComponent;

Related articles: How to access Gantt API