-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection_example.js
More file actions
39 lines (33 loc) · 928 Bytes
/
selection_example.js
File metadata and controls
39 lines (33 loc) · 928 Bytes
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
import React, { Component } from 'react'
import { SMTable, SMTableSelection } from 'sm-react-table'
// basic selection example
class Example extends Component {
constructor(props) {
super(props)
this.state = {
selection: new SMTableSelection()
}
}
handleSelection() {
console.log(this.state.selection.selected())
}
render() {
let columns = [
{ name: 'NAME', title: 'Name', width: 200 },
{ name: 'AGE', title: 'Age', width: 100 },
{ name: 'EMPLOYER', 'title': 'Employer', width: 100 }
]
let rows = [
{ NAME: 'Eddard Stark', AGE: '36', EMPLOYER: 'Winterfell' },
{ NAME: 'Robert Baratheon', AGE: '36', EMPLOYER: 'Self-employed' }
]
return
<SMTable
rows={rows}
columns={columns}
selectionEnabled={true}
selection={this.state.selection}
selectionColumnEnabled={true}
onSelectionChange={this.handleSelection}/>;
}
}