Skip to main content

oncancel

Description​

A function that is called on click of the Cancel button

Usage​

oncancel: (
value: {
field: string | number,
type?: "number" | "text" | "date" | "tuple",
predicate?: "month" | "year",
filter?: string,
includes?: any[],
value?: any,
}
) => void;

Parameters​

The callback of the event takes the value object with the following parameters:

  • field - (required) the id of a field. It should be one of the field id from the fields property, if it is defined
  • type - (optional) filter type: "text" (default) | "number" | "date" | "tuple"
  • filter - (optional) the filter operator available for this type
  • predicate - (optional) Date part extractor ("month" or "year") for date fields
  • value - (optional) the value in the input field
  • includes - (optional) an array of the included values (strings, numbers or dates).

Example​

<script>
import { getData } from "../data";
import { FilterEditor } from "@svar-ui/svelte-filter";

const { fields, options } = getData();

function handleCancel() {
console.log("Rule not applied")
}
</script>

<FilterEditor
field="age"
{options}
oncancel={handleCancel}
/>

Related articles: FilterEditor Guide