-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDataTable.js
More file actions
61 lines (53 loc) · 1.48 KB
/
DataTable.js
File metadata and controls
61 lines (53 loc) · 1.48 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
import React from "react";
import ReactTable from 'react-table-v6'
import Draggable from 'react-draggable';
import 'react-table-v6/react-table.css'
function DataTable({ columns, values, setCompIndex, index, setSidePlane, remover, keys }) {
const dataColumns = columns.map((val, index) => {
return {
Header: val,
accessor: val,
Cell: (props) => (
<div className={val || ''}>
<span>{props.value}</span>
</div>
),
width:
index === 0 && (1280 * 0.8333 - 30) / columns.length < 130
? 130
: undefined,
}
});
const data = values.map(val => {
let rows_data = {}
val.forEach((val2, index) => {
let col = columns[index];
rows_data[col] = val2;
})
return rows_data;
})
const handleSidePlane = () => {
setCompIndex(index)
// setSidePlane(true)
}
return (
<Draggable >
<div className="w-1/2" onClick={() => handleSidePlane()}>
{/* <button onClick={()=> remover(keys)} className="bg-red-700 text-white rounded-sm p-2">X</button> */}
<ReactTable
data={data}
columns={dataColumns}
getTheadThProps={() => {
return { style: { wordWrap: 'break-word', whiteSpace: 'initial' } }
}}
showPageJump={true}
showPagination={true}
defaultPageSize={10}
showPageSizeOptions={true}
minRows={10}
/>
</div>
</Draggable>
)
}
export default DataTable