Search and filter
isShowSearch adds a search box above the table. showFilterInputs adds a dropdown next to it, filled from filtersOptions, so the user can choose which field to search in.
vue
<template>
<VTable
:columns="columns"
:data="products"
isShowSearch
showFilterInputs
:filtersOptions="['name', 'category', 'status']"
clientSide
:itemsPerPage="5"
@Search="lastEvent = $event"
/>
<p class="demo-log">Search: {{ lastEvent ?? "type in the search box" }}</p>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { VTable, type Column, type SearchPayload } from "v-table-system";
import { products } from "./data";
const lastEvent = ref<string | SearchPayload>();
const columns: Column[] = [
{ key: "name", label: "Name" },
{ key: "category", label: "Category" },
{ key: "status", label: "Status" },
];
</script>The Search event
The event fires after the user stops typing, and right away when the dropdown changes.
| Setup | Payload |
|---|---|
| Search box only | "mouse" |
| Search box and dropdown | { keySearch: "category", inputValue: "audio" } |
Client-side search
With clientSide the table filters the rows itself, ignoring case:
- without the dropdown it looks in every visible column
- with the dropdown it looks only in the chosen field. An option can be a column key, a column label, or any other property of the rows.
Typing delay
searchDebounce is the wait in milliseconds between the last key press and the Search event. The default is 1000, or 300 with clientSide.
vue
<VTable isShowSearch :searchDebounce="500" ... />