Skip to content

Commit 6e1350c

Browse files
committed
add example for #1112
1 parent fdb04f8 commit 6e1350c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

examples/js/others/demo.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import MouseEventTable from './mouse-event-table';
33
import TableInTabs from './table-in-tabs';
44
import GetPageNumByKeyTable from './expose-api-table';
5+
import PrintableTable from './printable-table';
56
import { Col, Panel } from 'react-bootstrap';
67

78
class Demo extends React.Component {
@@ -23,6 +24,10 @@ class Demo extends React.Component {
2324
<h5>Use expose API by BootstrapTable to get page number by rowkey</h5>
2425
<GetPageNumByKeyTable/>
2526
</Panel>
27+
<Panel header={ 'Printable Table Example)' }>
28+
<h5>Source in /examples/js/others/printable-table.js</h5>
29+
<PrintableTable/>
30+
</Panel>
2631
</Col>
2732
);
2833
}

examples/js/others/printable-table.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint max-len: 0 */
2+
/* eslint no-console: 0 */
3+
import React from 'react';
4+
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
5+
6+
7+
const products = [];
8+
9+
function addProducts(quantity) {
10+
const startId = products.length;
11+
const fruits = [ 'banana', 'apple', 'orange', 'tomato', 'strawberries' ];
12+
for (let i = 0; i < quantity; i++) {
13+
const id = startId + i;
14+
products.push({
15+
id: id,
16+
name: 'Fruit name is ' + fruits[i],
17+
price: 2100 + i
18+
});
19+
}
20+
}
21+
22+
addProducts(5);
23+
24+
const options = {
25+
printToolBar: false
26+
};
27+
28+
export default class Printable extends React.Component {
29+
render() {
30+
return (
31+
<BootstrapTable data={ products } search={ true } options={ options }>
32+
<TableHeaderColumn dataField='id' isKey={ true } searchable={ false }>Product ID</TableHeaderColumn>
33+
<TableHeaderColumn dataField='name'>Fruit Name</TableHeaderColumn>
34+
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
35+
</BootstrapTable>
36+
);
37+
}
38+
}

0 commit comments

Comments
 (0)