Skip to main content

update-task

Description

Fires when updating a task

Usage

"update-task": ({
id: string | number,
task: object,
diff?: number,
inProgress?: boolean,
eventSource?: string
}) => boolean | void;

Parameters

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

  • id - (required) the task ID
  • task - (required) the task object. The list of parameters you can see here: tasks. You can also specify the following parameters:
    • level - (required) the nesting level of a task in the tasks tree
    • data - (optional) an array of objects with child tasks objects if any (parameters are the same as for the task object)
    • key - (required) the name of the data field which should be unique for each control type (e.g., text, duration, progress, etc.)
  • diff - (optional) the number of units for the start or/and end date values to be changed (in the tasks object)
  • inProgress - (optional) if true, marks that the task update is in progress
  • eventSource - (optional) the name of an action that triggered the update
info

For handling the actions you can use the Event Bus methods

Example

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

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

function MyComponent() {
const data = getData();

const apiRef = useRef();

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

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

export default MyComponent;

Related articles: How to access Gantt API