-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
68 lines (62 loc) · 1.7 KB
/
main.ts
File metadata and controls
68 lines (62 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import "@ag-grid-community/styles/ag-grid.css";
import "@ag-grid-community/styles/ag-theme-quartz.css";
import {
ColDef,
ColGroupDef,
GridApi,
GridOptions,
ModuleRegistry,
createGrid
} from "@ag-grid-community/core";
import { ClientSideRowModelModule } from "@ag-grid-community/client-side-row-model";
import { ColumnsToolPanelModule } from "@ag-grid-enterprise/column-tool-panel";
import { MenuModule } from "@ag-grid-enterprise/menu";
import { IOlympicData } from "./interfaces";
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ColumnsToolPanelModule,
MenuModule
]);
const columnDefs: ColDef[] = [
{ field: "athlete", minWidth: 200 },
{
field: "age"
},
{
field: "country",
minWidth: 200
},
{ field: "year" },
{ field: "sport", minWidth: 200 },
{ field: "gold" },
{ field: "silver" },
{ field: "bronze" },
{ field: "total" }
];
let gridApi: GridApi<IOlympicData>;
const gridOptions: GridOptions<IOlympicData> = {
columnDefs: columnDefs,
defaultColDef: {
flex: 1,
editable: true,
enableRowGroup: true,
enablePivot: true,
enableValue: true,
resizable: true,
filter: true
},
rowDragManaged: true,
enableRangeSelection: true,
enableRangeHandle: true,
enableFillHandle: true,
rowGroupPanelShow: "always",
pivotPanelShow: "always",
animateRows: true
//columnMenu: "legacy",
};
// setup the grid after the page has finished loading
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
.then((response) => response.json())
.then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));