AdaptTable for Element Plus

Saved views in Element Plus

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

The same feature in the other kits

More Element Plus features

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