AdaptTable for Naive UI

Saved views in Naive UI

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/naive-ui";
import { filters } from "@adapttable/naive-ui/filters";
import { savedViews } from "@adapttable/naive-ui/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/naive-ui @adapttable/vue @adapttable/core naive-ui

The same feature in the other kits

More Naive UI features

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