AdaptTable for Ant Design

Nested tables in Ant Design

Open a row and the panel holds another Ant Design 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 renderRowDetail.

The expand chevron and both tables are Ant Design.

The chevron maps onto antd's native expandable API; the inner table is another antd DataTable, so the nested orders are antd records rather than expandedRowRender markup.

The code

import { DataTable } from "@adapttable/antd";

export function People({ rows, columns, orderColumns }) {
  return (
    <DataTable
      data={rows}
      columns={columns}
      rowKey={(row) => row.id}
      nestedTable={(row) => ({
        label: `Orders for ${row.name}`,
        table: (defaults) => (
          <DataTable
            {...defaults}
            data={row.orders}
            columns={orderColumns}
            rowKey={(order) => order.id}
          />
        ),
      })}
    />
  );
}

Install

pnpm add @adapttable/antd @adapttable/core antd

The same feature in the other kits

More Ant Design features

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