getParentIds()
Description
Returns the IDs of parent tasks of the specified child task
Usage
getParentIds({
id: string | number
}): (string|number)[];
Parameters
id
- (required) the ID of the task
Returns
The method returns an array of parent's ID
Example
const { ToDo, Toolbar } = todo;
const { users, projects, tags } = getData();
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1 #tag1" },
{ id: "1.1", text: "Task 1.1", parent: "1" },
{ id: "1.1.1", text: "Task 1.1.1", parent: "1.1" },
{ id: "1.2", text: "Task 1.2", parent: "1" },
],
users,
projects
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// get parents of the task
console.log(list.getParentIds({ id: "1.1.1" })); // ['1.1', '1']
Related article: Task object/Id