Skip to main content

update-rule

Description

Use for finalized changes after clicking "Apply".

Usage

"update-rule": ({
id: string | number,
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
    • type - (optional) the type of a value: "text" (default, for string values), "number", "date", "tuple"
    • filter - (optional) (optional) the filter operator
    • includes - (optional) an array of the included values (strings, numbers or dates)
    • value - (optional) the value passed to the field.

Example

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

const { value, fields, options } = getData();

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

</script>

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

Related articles: