-
Notifications
You must be signed in to change notification settings - Fork 931
/
index.js
168 lines (161 loc) · 6.72 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import React, { useState } from 'react';
import MUIDataTable from '../../src/';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
function Example() {
const [responsive, setResponsive] = useState('vertical');
const [tableBodyHeight, setTableBodyHeight] = useState('400px');
const [tableBodyMaxHeight, setTableBodyMaxHeight] = useState('');
const [searchBtn, setSearchBtn] = useState(true);
const [downloadBtn, setDownloadBtn] = useState(true);
const [printBtn, setPrintBtn] = useState(true);
const [viewColumnBtn, setViewColumnBtn] = useState(true);
const [filterBtn, setFilterBtn] = useState(true);
const columns = [{ name: 'Name', options: { filterOptions: { fullWidth: true } } }, 'Title', 'Location'];
const options = {
search: searchBtn,
download: downloadBtn,
print: printBtn,
viewColumns: viewColumnBtn,
filter: filterBtn,
filterType: 'dropdown',
responsive,
tableBodyHeight,
tableBodyMaxHeight,
onTableChange: (action, state) => {
console.log(action);
console.dir(state);
},
};
const data = [
['Gabby George', 'Business Analyst', 'Minneapolis'],
['Aiden Lloyd', "Business Consultant for an International Company and CEO of Tony's Burger Palace", 'Dallas'],
['Jaden Collins', 'Attorney', 'Santa Ana'],
['Franky Rees', 'Business Analyst', 'St. Petersburg'],
['Aaren Rose', null, 'Toledo'],
['Johnny Jones', 'Business Analyst', 'St. Petersburg'],
['Jimmy Johns', 'Business Analyst', 'Baltimore'],
['Jack Jackson', 'Business Analyst', 'El Paso'],
['Joe Jones', 'Computer Programmer', 'El Paso'],
['Jacky Jackson', 'Business Consultant', 'Baltimore'],
['Jo Jo', 'Software Developer', 'Washington DC'],
['Donna Marie', 'Business Manager', 'Annapolis'],
];
return (
<React.Fragment>
<FormControl>
<InputLabel id="demo-simple-select-label">Responsive Option</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={responsive}
style={{ width: '200px', marginBottom: '10px', marginRight: 10 }}
onChange={e => setResponsive(e.target.value)}>
<MenuItem value={'vertical'}>vertical</MenuItem>
<MenuItem value={'standard'}>standard</MenuItem>
<MenuItem value={'simple'}>simple</MenuItem>
<MenuItem value={'scroll'}>scroll (deprecated)</MenuItem>
<MenuItem value={'scrollMaxHeight'}>scrollMaxHeight (deprecated)</MenuItem>
<MenuItem value={'stacked'}>stacked (deprecated)</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Table Body Height</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={tableBodyHeight}
style={{ width: '200px', marginBottom: '10px', marginRight: 10 }}
onChange={e => setTableBodyHeight(e.target.value)}>
<MenuItem value={''}>[blank]</MenuItem>
<MenuItem value={'400px'}>400px</MenuItem>
<MenuItem value={'800px'}>800px</MenuItem>
<MenuItem value={'100%'}>100%</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Max Table Body Height</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={tableBodyMaxHeight}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setTableBodyMaxHeight(e.target.value)}>
<MenuItem value={''}>[blank]</MenuItem>
<MenuItem value={'400px'}>400px</MenuItem>
<MenuItem value={'800px'}>800px</MenuItem>
<MenuItem value={'100%'}>100%</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Search Button</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={searchBtn}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setSearchBtn(e.target.value)}>
<MenuItem value={'true'}>{'true'}</MenuItem>
<MenuItem value={'false'}>{'false'}</MenuItem>
<MenuItem value={'disabled'}>disabled</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Download Button</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={downloadBtn}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setDownloadBtn(e.target.value)}>
<MenuItem value={'true'}>{'true'}</MenuItem>
<MenuItem value={'false'}>{'false'}</MenuItem>
<MenuItem value={'disabled'}>disabled</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Print Button</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={printBtn}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setPrintBtn(e.target.value)}>
<MenuItem value={'true'}>{'true'}</MenuItem>
<MenuItem value={'false'}>{'false'}</MenuItem>
<MenuItem value={'disabled'}>disabled</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">View Column Button</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={viewColumnBtn}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setViewColumnBtn(e.target.value)}>
<MenuItem value={'true'}>{'true'}</MenuItem>
<MenuItem value={'false'}>{'false'}</MenuItem>
<MenuItem value={'disabled'}>disabled</MenuItem>
</Select>
</FormControl>
<FormControl>
<InputLabel id="demo-simple-select-label">Filter Button</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={filterBtn}
style={{ width: '200px', marginBottom: '10px' }}
onChange={e => setFilterBtn(e.target.value)}>
<MenuItem value={'true'}>{'true'}</MenuItem>
<MenuItem value={'false'}>{'false'}</MenuItem>
<MenuItem value={'disabled'}>disabled</MenuItem>
</Select>
</FormControl>
<MUIDataTable title={'ACME Employee list'} data={data} columns={columns} options={options} />
</React.Fragment>
);
}
export default Example;