-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample1.tsx
More file actions
49 lines (42 loc) · 1.19 KB
/
Sample1.tsx
File metadata and controls
49 lines (42 loc) · 1.19 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
import React, { useState, useEffect } from "react";
import { WSCanvas, useWindowSize } from "./lib";
export function Sample1() {
const [rows, setRows] = useState<any[][]>([]);
const winSize = useWindowSize();
const ROWS = 50000;
const COLS = 200;
useEffect(() => {
const _rows = [];
for (let ri = 0; ri < ROWS; ++ri) {
const row = [];
for (let ci = 0; ci < COLS; ++ci) {
row.push("r:" + ri + " c:" + ci);
}
_rows.push(row);
}
setRows(_rows);
}, []);
return <div>
<WSCanvas
fullwidth
height={winSize.height * .8}
containerStyle={{ margin: "1em" }}
rows={rows}
rowGetCellData={(row, colIdx) => row[colIdx]}
prepareCellDataset={() => rows.slice()}
commitCellDataset={(q) => setRows(q)}
rowSetCellData={(row, colIdx, value) => row[colIdx] = value}
colWidth={(ci) => {
let w = 50;
for (let i = 0; i < ci; ++i) {
w += 50;
if (w > 200) w = 50;
}
return w;
}}
rowsCount={rows.length} colsCount={COLS}
showRowNumber={true} showColNumber={true} showFilter={true}
frozenRowsCount={1} frozenColsCount={1}
/>
</div>
}