-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathApp.js
64 lines (60 loc) · 1.7 KB
/
App.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
import React from 'react';
import './App.css';
import DataTable from './DataTable'
import data from './data'
export default class App extends React.Component{
constructor(props) {
super(props);
this.state = {
columns: [
{ title: "name", data: "name" },
{ title: "position", data: "position" },
{ title: "salary", data: "salary" },
{ title: "start_date", data: "start_date" },
{ title: "office", data: "office" },
{ title: "extn", data: "extn" }
],
searchValue: '',
options: {
dom: 'lrtip',
// paging: false,
// scrollX: true,
// scrollY: '100%',
// scrollCollapse: false,
// autoWidth: false,
// info: false,
}
};
this.dataTableRef = React.createRef();
}
onChangeSearch = (e) => {
const { value } = e.target;
const searchValue = value;
this.setState({ searchValue });
this.dataTableRef.current.search(searchValue);
};
render() {
const {
columns,
options,
searchValue
} = this.state;
return (
<div>
<input
value={searchValue}
onChange={this.onChangeSearch}
autoComplete={'off'}
type="text"
placeholder="Search ..."
/>
<DataTable
ref={this.dataTableRef}
data={data}
columns={columns}
options={options}
/>
</div>
);
}
}