-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBasicExample.tsx
108 lines (99 loc) · 2.17 KB
/
BasicExample.tsx
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import * as React from 'react';
import styled from '@emotion/styled';
import { RFDataGrid, RFDGColumn } from '../react-frame-datagrid';
interface Props {}
interface IListItem {
id: string;
title: string;
writer: string;
createAt: string;
}
const list = Array.from(Array(1000)).map((v, i) => ({
values: {
id: `ID_${i}`,
title: `title_${i}`,
writer: `writer_${i}`,
createAt: `2022-09-08`,
},
}));
function BasicExample(props: Props) {
const [columns, setColumns] = React.useState<RFDGColumn<IListItem>[]>([
{
key: 'id',
label: '아이디 IS LONG !',
width: 100,
},
{
key: 'title',
label: '제목',
width: 300,
itemRender: item => {
return `${item.writer}//${item.title}`;
},
},
{
key: 'writer',
label: '작성자',
width: 100,
itemRender: item => {
return `${item.writer}//A`;
},
},
{
key: 'createAt',
label: '작성일A',
width: 100,
},
{
key: 'createAt',
label: '작성일B',
width: 100,
},
{
key: 'createAt',
label: '작성일C',
width: 100,
},
{
key: 'createAt',
label: '작성일D',
width: 100,
},
{
key: 'createAt',
label: '작성일E',
width: 100,
},
]);
const [width, setWidth] = React.useState(600);
const containerRef = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
if (containerRef.current) {
setWidth(containerRef.current.clientWidth);
}
}, []);
return (
<Container ref={containerRef}>
<RFDataGrid<IListItem>
width={width}
height={400}
data={list}
columns={columns}
onChangeColumns={(columnIndex, width, columns) => {
console.log('onChangeColumnWidths', columnIndex, width, columns);
setColumns(columns);
}}
rowSelection={{
selectedIds: [],
onChange: (ids, selectedAll) => {
console.log('onChange rowSelection', ids, selectedAll);
},
}}
/>
</Container>
);
}
const Container = styled.div`
font-size: 13px;
`;
export default BasicExample;