AdaptTable for Vue Unstyled

Saved views in Vue Unstyled

A view is the table's state — search, sort, filters and the column layout — saved under a name.

Save one from the views menu and pick it again later to put the table back the way it was. The list lives in this browser's storage, or in any store you hand savedViews.

The code

<script setup lang="ts">
import type { ColumnDef } from "@adapttable/vue";
import { DataTable } from "@adapttable/vue-unstyled";
import { filters } from "@adapttable/vue-unstyled/filters";
import { savedViews } from "@adapttable/vue-unstyled/saved-views";

defineProps<{ rows: readonly Person[] }>();

const columns: ColumnDef<Person>[] = [
  { key: "name", sortable: true },
  { key: "team" },
  { key: "budget", sortable: true },
];
const rowKey = (row: Person) => row.id;
const features = [
  filters<Person>([]),
  savedViews({ storageKey: "people-views", urlKey: "people" }),
];
</script>

<template>
  <DataTable
    :data="rows"
    :columns="columns"
    :row-key="rowKey"
    url-key="people"
    :features="features"
  />
</template>

Install

pnpm add @adapttable/vue-unstyled @adapttable/vue @adapttable/core

The same feature in the other kits

More Vue Unstyled features

Reference: saved-views, url-state. More of this kit: AdaptTable for Vue Unstyled, or the live demo.