Skip to main content

change-rule

Description

Fires each time a change is made to the filtering rule

Usage

"change-rule": ({
id: string,
rule: {
field: string,
type?: string,
filter?: string,
includes?: any[],
value?: any
};
}) => void;

Parameters

The callback of the action takes an object with the following parameters:

  • id - (required) the id of a field for which the rule is updated
  • rule - (required) a filtering rule with the following parameters:
    • field - (required) the id of a field. It should be the same as the corresponding field id of the fields property
    • type - (optional) filter type: "text" (default) | "number" | "date" | "tuple"
    • filter - (optional) the filter operator available for this type
    • value - (optional) the value in the field
    • includes - (optional) an array of the included values (strings, numbers or dates).

Example

<script>
import { getData } from "./common/data";
import { FilterBuilder } from "wx-svelte-filter";

const { fields, options } = getData();

const init = (api) => {
api.on("change-rule", ev => {
console.log("The id of the field for which the rule was changed:" (ev.id));
});
}
</script>

<FilterBuilder {options} {fields} {init} />

Related articles: