-
Notifications
You must be signed in to change notification settings - Fork 782
/
Copy pathmulti-sort-table.js
41 lines (33 loc) · 1 KB
/
multi-sort-table.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
/* eslint max-len: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
const products = [];
function addProducts(quantity) {
const startId = products.length;
let price = 2100;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
if (id % 5 === 0) {
price += 100;
}
products.push({
id: id,
name: 'Item name ' + (id % 3 + 1),
price: price
});
}
}
addProducts(15);
export default class MultiSortTable extends React.Component {
render() {
return (
<div>
<BootstrapTable ref='table' data={ products } multiColumnSort={ 2 }>
<TableHeaderColumn dataField='id' isKey={ true } dataSort={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name' dataSort={ true }>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price' dataSort={ true }>Product Price</TableHeaderColumn>
</BootstrapTable>
</div>
);
}
}