Skip to main content

api.getTask(id)

Description

Gets an object with the task configuration

Usage

api.getTask(id): object;

Parameters

  • id - the id of a task

Returns

The method returns an object with the tasks parameters:

{
id: string|number,
start: Date,
end?: Date,
duration?:number,

text?: string,
progress?: number,
parent?: string|number,
type?: "task" | "project" | "milestone"|any,
open?:boolean,
lazy?:boolean,
base_start?: Date,
base_end?: Date,
base_duration?: number
}

Example of the object that is returned:

{
id: 3,
start: Thu Mar 05 2020 00:00:00 GMT+0300 (Moscow Standard Time),
end: Sat Mar 07 2020 00:00:00 GMT+0300 (Moscow Standard Time),
text: 'Task 3',
progress: 6,
type:"project",
duration:2,
parent:0
}

Example

The example shows how to output to console data on the task with "id:3".

<script>
import { getData } from "../data";
import { Gantt } from "@wx/svelte-gantt";

const data = getData();

let api;

$: if (api) {
const task = api.getTask(3);
console.log("Task:", task);
}

</script>

<Gantt
bind:api
tasks = {data.tasks}
links={data.links}
scales={data.scales}
/>

Related articles: