Sorting and filtering tasks
Sorting tasks
The library allows you to sort tasks in the list after initialization of To Do List. There are two ways to view the tasks in the sorted order:
via the Sort by option of the Toolbar menu. You may sort tasks by text, due date, completion date, creation date, or editing date
via the
setSort()
method. You may specify your own search function or implement sorting by a task attribute. For instance:
list.setSort({
by: task => task.id, // or by: "text"
dir: "asc",
// tree: true // enable tree sort, false by default
});
Filtering tasks
You can find the tasks that match the specified criteria in 2 ways:
via the search bar of Toolbar
through the
setFilter()
method. The method supports the strict mode of filtering that allows you to filter tasks by the exact match.
// filter data by the specified rules
list.setFilter({
match: "#tag1",
highlight: true,
strict: true
});
To reset filtering, call the method without parameters:
// reset filtering
list.setFilter({});