update-assignment
The functionality is available in PRO Edition only
PRODescription
Fires when updating a resource assignmentUsage
"update-assignment": ({
id: string | number,
assignment: {
id?: string | number,
task?: string | number,
resource?: string | number,
units?: number,
[key: string]: any,
},
}) => boolean | void;
info
For handling the actions you can use the Event Bus methods. Returning false from the action handler will block the action (see Preventing actions)
Parameters
The callback of the update-assignment action can take an object with the following parameters:
id- (required) the ID of the assignment to be updatedassignment- (required) an object with the fields to update:id- (optional) the assignment IDtask- (optional) the task ID the assignment belongs toresource- (optional) the new resource ID; the new resource must not already be assigned to this taskunits- (optional) the new allocation percentage from 0 to 100
Example
Use the api.exec method to trigger the action:
import { getData } from "./common/data";
import { Gantt } from "@svar-ui/react-gantt";
import { useState, useRef } from "react";
function App() {
const data = getData();
const api = useRef();
function init(ganttApi) {
api.current = ganttApi;
}
function updateAllocation() {
api.current.exec("update-assignment", {
id: 1,
assignment: { units: 50 },
});
}
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
init={init}
/>
);
}
Related articles: