selectTask()
Description
Selects the specified task by its ID
Usage
selectTask({
id: string | number,
join?: boolean // false by default
}): void;
Parameters
id
- (required) the ID of a taskjoin
- (optional) if true, adds the specified task to the collection of selected tasks, saving the IDs of previously selected tasks
info
Calling the method with join: false
invokes the unselect-task
event for previously selected tasks
Example
const { ToDo, Toolbar } = todo;
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" },
],
selected: ["1.1"]
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
console.log(list.getSelection()); // -> ['1.1']
list.selectTask({
id: "1.1.1",
join: true
});
console.log(list.getSelection()); // -> ['1.1', '1.1.1']
Change log: The join
parameter was added in v1.1
Related article: Multiple select and bulk operations