api.getTaskResources(id)
The functionality is available in PRO Edition only
PRODescription
Gets all resources assigned to a taskUsage
api.getTaskResources(id): TResourceAssignment[];
Parameters
id- the id of the task
Returns
The method returns an array of objects for each resource assigned to the specified task. Returns an empty array if no resources are assigned.
Each object is a combination of the assignment and resource data. It contains all resource properties (such as id, name, role, etc.) together with the assignment fields:
units— allocation percentage (0–100)assignmentId— the ID of the assignment record
Example
import { getData } from "../data";
import { Gantt } from "@svar-ui/react-gantt";
const data = getData();
function init(api) {
const resources = api.getTaskResources(1);
// [{ id: "r1", name: "Alice", role: "Developer", units: 100, assignmentId: 1 }, ...]
console.log("Assigned resources:", resources);
}
export default function App() {
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
resources={data.resources}
assignments={data.assignments}
init={init}
/>
);
}
Related articles: