Skip to content

Commit 0dfded4

Browse files
committed
examples for #1009
1 parent 94b4451 commit 0dfded4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-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: 'The white-space property specifies how white-space inside an element is handled, default is normal ' + id,
15+
price: 2100 + i
16+
});
17+
}
18+
}
19+
20+
addProducts(5);
21+
22+
export default class ColumnStyleTable extends React.Component {
23+
render() {
24+
return (
25+
<BootstrapTable data={ products }>
26+
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
27+
<TableHeaderColumn dataField='name' tdStyle={ { whiteSpace: 'normal' } }>Product Name</TableHeaderColumn>
28+
<TableHeaderColumn dataField='price' thStyle={ { 'fontWeight': 'lighter' } }>Product Price</TableHeaderColumn>
29+
</BootstrapTable>
30+
);
31+
}
32+
}

examples/js/column/demo.js

Lines changed: 14 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 ColumnWordWrapTable from './column-style-table';
67
import ColumnTitleTable from './column-title-table';
78
import TdAttributeTable from './td-attribute-table';
89

@@ -37,6 +38,19 @@ class Demo extends React.Component {
3738
</div>
3839
</div>
3940
</div>
41+
<div className='col-md-offset-1 col-md-8'>
42+
<div className='panel panel-default'>
43+
<div className='panel-heading'>Column Word Wrap Example</div>
44+
<div className='panel-body'>
45+
<h5>Source in /examples/js/column/column-style-table.js</h5>
46+
<span>This example show you how to configure style on td cell for tuning Product Name as word wrap<br/></span>
47+
<span style={ { color: 'red' } }>
48+
<b>You can use <code>tdStyle</code> ro <code>thStyle</code> to configure your own css, but we highly recommend you do not set <code>width</code>, <code>min-width</code> and <code>max-width</code></b>
49+
</span>
50+
<ColumnWordWrapTable />
51+
</div>
52+
</div>
53+
</div>
4054
<div className='col-md-offset-1 col-md-8'>
4155
<div className='panel panel-default'>
4256
<div className='panel-heading'>Column Title Example</div>

0 commit comments

Comments
 (0)