AdaptTable for Naive UI

Row and column virtualization in Naive UI

Compose virtualize() and the table renders the rows in view plus a small overscan, whatever the dataset's size — forty thousand rows on this page, a few dozen of them in the page at once.

The scroll box scrolls rather than the page, and sorting and filtering keep working on the whole dataset rather than on what is drawn. virtualize({ virtualizeColumns: true }) does the same across, for column sets wider than the box.

The code

<script setup lang="ts">
import type { ColumnDef } from "@adapttable/vue";
import { DataTable } from "@adapttable/naive-ui";
import { virtualize } from "@adapttable/naive-ui/virtualize";

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 = [virtualize({ maxHeight: 480 })];
</script>

<template>
  <DataTable
    :data="rows"
    :columns="columns"
    :row-key="rowKey"
    pagination-mode="infinite"
    :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: virtualization. More of this kit: AdaptTable for Naive UI, or the live demo.