Filtering data
The Grid API allows adding filters to column headers. It's possible to apply built-in filters or add custom filters. By default, AND logic is applied to built-in filters but you can modify filter settings and override the default logic to implement OR logic instead.
Applying built-in filters
You can add basic filters to column headers ("text", "richselect", "datepicker") using the filter parameter of the header element of the columns property. For example, for the text type, you can set the filter value to "text" or define it inside the type object.
<script setup>
import { Grid } from "@svar-ui/vue-grid";
import { getData } from "./common/data";
const { data } = getData();
const columns = [
{ id: "id", width: 50 },
{
id: "firstName",
header: { filter: "text" },
footer: "First Name",
width: 150,
},
{
id: "lastName",
header: { filter: { type: "text" } },
footer: "Last Name",
width: 150,
},
{
id: "email",
header: "Email",
footer: "Email",
},
{
id: "country",
header: {
filter: {
type: "richselect",
config: {
options: countries,
},
},
},
options: countries,
},
];
</script>
<template>
<Grid :data="data" :columns="columns" />
</template>
Related sample: Filters