AdaptTable for Nuxt UI

Nested tables in Nuxt UI

Open a row and the panel holds another Nuxt UI table — the same component, not a hand-built list. Each person has recent orders; the inner table has its own columns and row keys.

nestedTable() mounts the kit's DataTable with defaults that keep the two tables from fighting over the URL. Rows with no nested table can still use rowDetail().

The expand chevron and both tables are Nuxt UI.

The code

<script setup lang="ts">
import { h } from "vue";
import type { ColumnDef } from "@adapttable/vue";
import { DataTable } from "@adapttable/nuxt-ui";
import { nestedTable } from "@adapttable/nuxt-ui/nested-table";

interface Order {
  id: string;
  item: string;
}

interface Customer {
  id: string;
  name: string;
  orders: Order[];
}

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

const columns: ColumnDef<Customer>[] = [{ key: "name" }];
const orderColumns: ColumnDef<Order>[] = [{ key: "item" }];
const rowKey = (row: Customer) => row.id;
const features = [
  nestedTable<Customer>((row) => ({
    label: `Orders for ${row.name}`,
    table: (defaults) =>
      h(DataTable<Order>, {
        ...defaults,
        data: row.orders,
        columns: orderColumns,
        rowKey: (order: Order) => order.id,
      }),
  })),
];
</script>

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

Install

pnpm add @adapttable/nuxt-ui @adapttable/vue @adapttable/core @nuxt/ui

The same feature in the other kits

More Nuxt UI features

Reference: tree-data, row-expansion. More of this kit: AdaptTable for Nuxt UI, or the live demo.