Skip to main content

fields

Description

Required. An array of objects with fields data

Usage

fields: {
id: string | number,
label: string,
type: string,
format?: string | ((v: any) => string);
}[];

Parameters

Each field object has the following parameters:

  • id - (required) the id of a field
  • label - (required) a field label
  • type - (required) the type of a field which can be "text"", "number", "tuple" or "date"
  • format - (optional) fornumber or date formatter, which can be one of the following:
    • a formatting function for number, tuple or date: (value: number|Date) => string
    • a formatting string for date

Example

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

const { value, options } = getData();

const fields = [
{ id: "first_name", label: "First Name", type: "text"},
{ id: "age", label: "Age", type: "number",},
{ id: "start", label: "Start Date", type: "date" },
];

</script>

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

Related articles: FilterBuilder Guide