Skip to main content

filter

Description

Optional. Specifies what context to show for the specified targets

Usage

filter?: (option: IMenuOption, item: any) => boolean;

Parameters

The filter function receives two arguments:

  • option — a single menu option (IMenuOption) from the options collection
  • item — the context object returned by the resolver function for the clicked element

The function should return:

  • true - the menu option will be shown.
  • false - the menu option will be hidden.

Example

<script>
const filterMenu = (menuItem, task) => {
// hide the "delete" item for projects
if (menuItem.id === "delete" && task.type === "project") return false;
return true;
}
</script>

<ActionMenu {options} resolver={getTasks} filter={filterMenu}>

In the above example:

  • menuItem - a single record from the options collection
  • task - the result of the resolver (getTasks()) function call

Related article: Different context for different targets

Related sample: