gridOptions
[
[
"Team",
false
],
[
"Wins",
"number"
],
[
"Pf",
"number"
],
[
"Pa",
"number"
]
]import { AllCommunityModule, ModuleRegistry, themeQuartz } from "ag-grid-community";
import { defineTable } from "@sportsdataverse/sdvtables";
import { gridOptions } from "@sportsdataverse/sdvtables/aggrid";
import { prepare } from "@sportsdataverse/sdvtables/html";
ModuleRegistry.registerModules([AllCommunityModule]);
// 2024 regular season, nflverse games
const rows = [
{ team: "KC", wins: 15, pf: 385, pa: 326 },
{ team: "BUF", wins: 13, pf: 525, pa: 368 },
{ team: "LAC", wins: 11, pf: 402, pa: 301 },
];
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [c.logo("team", { league: "nfl", height: 28 }), c.int("wins"), c.int("pf"), c.int("pa")])
.theme("sdv")
.rowKey("team")
.build();
await prepare(spec);
const options = gridOptions(spec, rows, { theme: themeQuartz, teamRows: { key: "team", league: "nfl" } });
// in the page: createGrid(document.querySelector("#grid"), options), from ag-grid-community
options.columnDefs.map((c) => [c.headerName, c.cellDataType]);
Tags: docstring · gridOptions. All sdvtables examples.