Skip to main content

api.exec()

Description

Allows triggering Gantt actions

Usage

api.exec(
action,
config
);
```

## 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**](/api/overview/actions_overview)
:::

## Example

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

```jsx
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
import { useRef } from "react";

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

const clearTaskText = () => {
if (apiRef.current) {
apiRef.current.exec("update-task", {
id: 3,
task: { text: "" }
});
}
};

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

export default GanttComponent;
```

**Related articles:**
- [Working with server](/guides/working_with_server)
- [How to access Gantt API](/api/how_to_access_api)