tanstackTable
[
[
"team",
"Team"
],
[
"wins",
"Wins"
],
[
"pf",
"Pf"
]
]import { createSortedRowModel, rowSortingFeature, tableFeatures } from "@tanstack/table-core";
import { defineTable } from "@sportsdataverse/sdvtables";
import { prepare } from "@sportsdataverse/sdvtables/html";
import { tanstackTable } from "@sportsdataverse/sdvtables/tanstack-table";
const rows = [
{ team: "KC", wins: 15, pf: 385 },
{ team: "BUF", wins: 13, pf: 525 },
{ team: "LAC", wins: 11, pf: 402 },
];
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [c.logo("team", { league: "nfl", height: 28 }), c.int("wins"), c.int("pf")])
.rowKey("team")
.build();
await prepare(spec);
const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel() });
const { options } = tanstackTable(spec, rows, { features });
// in React: useTable(options), from @tanstack/react-table; in Svelte: createTable(options)
options.columns.map((c) => [c.id, c.header]);
Tags: docstring · tanstackTable. All sdvtables examples.