Skip to content

DataTable ​

A table with sort, a global search, column filters (text, list, range), pagination and selection. In server mode it only shows the rows it gets and asks for the next ones with the query event. Its state can live in the URL.

ts
import { DataTable } from '@zairakai/vue-components/Data'

Usage ​

vue
<DataTable />

Example ​

People
Status
Ada36open
Alan41closed
Grace85open
vue
<script setup>
  const columns = [
    { key: 'name', label: 'Name', sortable: true, filter: 'text' },
    { key: 'age', label: 'Age', type: 'number', sortable: true, align: 'end', filter: 'range' },
    { key: 'status', label: 'Status', filter: 'select', options: ['open', 'closed'] },
  ]

  const rows = [
    { id: 1, name: 'Ada', age: 36, status: 'open' },
    { id: 2, name: 'Alan', age: 41, status: 'closed' },
    { id: 3, name: 'Grace', age: 85, status: 'open' },
    { id: 4, name: 'Linus', age: 55, status: 'open' },
  ]
</script>

<template>
  <DataTable
    :columns="columns"
    :rows="rows"
    caption="People"
    searchable
    selectable
    :page-size="3"
  />
</template>

Props ​

NameTypeDefaultDescription
idstring
classstring
columnsarray[]The columns: { key, label, sortable, type: "text" | "number" | "date", align, format }.
rowsarray[]
rowKeystring'id'The property that identifies a row.
captionstring
sortobjectundefined{ key, direction: "asc" | "desc" }, with v-model:sort.
searchstringundefinedThe text filtered on, with v-model:search. A search box is shown when searchable.
searchablebooleanfalse
filtersobjectundefinedThe value of every column filter, by column key, with v-model:filters. A range is "min..max".
clearFiltersLabelstring'Clear filters'
filterLabelstring'Filter {column}'The label of a filter. Use {column}.
minLabelstring'from'
maxLabelstring'to'
allLabelstring'All'
searchLabelstring'Search'
pagenumberundefinedThe current page, starting at 1, with v-model:page.
pageSizenumber10
selectedarrayundefinedThe keys of the selected rows, with v-model:selected. A selection column is shown when selectable.
selectablebooleanfalse
serverSidebooleanfalseThe server sorts, filters and paginates: the table only shows the rows it gets and asks for the next ones with the query event. Give the total of rows.
totalnumber
loadingbooleanfalse
emptyTextstring'Nothing to show'
queryPrefixstringundefinedKeep the page, the sort and the search in the URL: ?page=2&sort=name&dir=desc&q=ada. The value is the prefix of the parameters, an empty string for none.
localestring
selectAllLabelstring'Select all rows'
selectRowLabelstring'Select row'

Events ​

NameDescription
update:sort
update:search
update:page
update:selected
update:filters
query

Slots ​

NameDescription
cell-${column.key}
empty

See Theming for the class hooks and the data-* state of the components.

Documentation of 1.4.4 , built from 8e9b054 on 1.4.4 by pipeline #2989941079 on 2026-10-26.