Skip to content

Commit adfcf00

Browse files
committed
add column title example
1 parent 4d25667 commit adfcf00

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint max-len: 0 */
2+
import React from 'react';
3+
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
4+
5+
6+
const products = [];
7+
8+
function addProducts(quantity) {
9+
const startId = products.length;
10+
for (let i = 0; i < quantity; i++) {
11+
const id = startId + i;
12+
products.push({
13+
id: id,
14+
name: 'Item name ' + id,
15+
price: 2100 + i
16+
});
17+
}
18+
}
19+
20+
addProducts(5);
21+
22+
export default class ColumnAlignTable extends React.Component {
23+
render() {
24+
return (
25+
<BootstrapTable data={ products }>
26+
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
27+
<TableHeaderColumn dataField='name' columnTitle={ true }>Product Name</TableHeaderColumn>
28+
<TableHeaderColumn dataField='price' columnTitle={ true }>Product Price</TableHeaderColumn>
29+
</BootstrapTable>
30+
);
31+
}
32+
}

examples/js/column/demo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import ColumnAlignTable from './column-align-table';
44
import ColumnWidthTable from './column-width-table';
55
import ColumnHideTable from './column-hide-table';
6+
import ColumnTitleTable from './column-title-table';
67

78
class Demo extends React.Component {
89
render() {
@@ -35,6 +36,15 @@ class Demo extends React.Component {
3536
</div>
3637
</div>
3738
</div>
39+
<div className='col-md-offset-1 col-md-8'>
40+
<div className='panel panel-default'>
41+
<div className='panel-heading'>Column Title Example</div>
42+
<div className='panel-body'>
43+
<h5>Source in /examples/js/column/column-title-table.js</h5>
44+
<ColumnTitleTable />
45+
</div>
46+
</div>
47+
</div>
3848
</div>
3949
);
4050
}

0 commit comments

Comments
 (0)