Skip to main content

set-filter

Description

Fires when filtering data by the specified criteria

Usage

"set-filter": ({
match?: string | null,
by?: string,
highlight?: boolean,
strict?: boolean
}) => void;

Parameters

The callback of the set-filter event can take an object with the following parameters:

  • match - (optional) a pattern to match
  • by - (optional) the parameter of the task object for searching
  • highlight - (optional) defines whether the matches found are highlighted
  • strict - (optional) true, if the strict mode of filtering is enabled; otherwise, false
info

To handle the inner events, you can use the Event Bus methods

Example

const { ToDo, Toolbar } = todo;
const { tasks, users, projects } = getData();

const list = new ToDo("#root", {
tasks,
users,
projects,
});

const toolbar = new Toolbar("#toolbar", {
api: list.api,
});

// subscribe to the "set-filter" event
list.api.on("set-filter", (obj) => {
console.log(obj);
});

Related article: Sorting and filtering tasks