-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
83 lines (72 loc) · 2.47 KB
/
index.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React, { useState } from "react";
import { render } from "react-dom";
import { AgGridColumn, AgGridReact } from "ag-grid-react";
import { simpleHttpRequest } from "ag-grid-community";
import MyCellRenderer from "./MyCellRenderer";
import { COLDEFS_WITHOUT_GROUPING } from "./columnDefs";
import GridOptionsPanel from "./GridOptionsPanel";
import PDFExportPanel from "./pdfExport/PDFExportPanel.js";
import "ag-grid-enterprise";
import "ag-grid-community/dist/styles/ag-grid.css";
import "ag-grid-community/dist/styles/ag-theme-alpine.css";
import "./style.css";
const App = () => {
const [gridApi, setGridApi] = useState(null);
const [columnApi, setColumnApi] = useState(null);
const [rowData, setRowData] = useState([]);
const onGridReady = params => {
setGridApi(params.api);
setColumnApi(params.columnApi);
simpleHttpRequest({
url: "https://www.ag-grid.com/example-assets/olympic-winners.json"
}).then(function(data) {
data.forEach(r => {
r.date = new Date();
});
setRowData(data.slice(1500, 2000));
});
};
const onFirstDataRendered = params => {
params.columnApi.autoSizeAllColumns();
};
const onColumnEverythingChanged = params => {
let selectionCol = params.columnApi.getColumn("selection-col");
if (selectionCol) {
params.columnApi.moveColumn(selectionCol, 0);
}
};
return (
<div>
<div className="form-wrap">
<GridOptionsPanel gridApi={gridApi} columnApi={columnApi} />
<PDFExportPanel gridApi={gridApi} columnApi={columnApi} />
</div>
<div className="grid-container">
<div className="ag-theme-alpine" style={{ height: "100%" }}>
<AgGridReact
columnDefs={COLDEFS_WITHOUT_GROUPING}
rowData={rowData}
suppressPropertyNamesCheck
defaultColDef={{
cellRenderer: "myCellRenderer",
filter: true,
sortable: true,
resizable: true,
enableRowGroup: true,
menuTabs: ["filterMenuTab"]
}}
frameworkComponents={{
myCellRenderer: MyCellRenderer
}}
groupSelectsChildren
rowSelection="multiple"
onColumnEverythingChanged={onColumnEverythingChanged}
onFirstDataRendered={onFirstDataRendered}
onGridReady={onGridReady}
/>
</div>
</div>
</div>
);
};
render(<App />, document.getElementById("root"));