Skip to content

Commit

Permalink
examples for #1009
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Feb 5, 2017
1 parent 94b4451 commit 0dfded4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/js/column/column-style-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint max-len: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';


const products = [];

function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'The white-space property specifies how white-space inside an element is handled, default is normal ' + id,
price: 2100 + i
});
}
}

addProducts(5);

export default class ColumnStyleTable extends React.Component {
render() {
return (
<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name' tdStyle={ { whiteSpace: 'normal' } }>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price' thStyle={ { 'fontWeight': 'lighter' } }>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
14 changes: 14 additions & 0 deletions examples/js/column/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import ColumnAlignTable from './column-align-table';
import ColumnWidthTable from './column-width-table';
import ColumnHideTable from './column-hide-table';
import ColumnWordWrapTable from './column-style-table';
import ColumnTitleTable from './column-title-table';
import TdAttributeTable from './td-attribute-table';

Expand Down Expand Up @@ -37,6 +38,19 @@ class Demo extends React.Component {
</div>
</div>
</div>
<div className='col-md-offset-1 col-md-8'>
<div className='panel panel-default'>
<div className='panel-heading'>Column Word Wrap Example</div>
<div className='panel-body'>
<h5>Source in /examples/js/column/column-style-table.js</h5>
<span>This example show you how to configure style on td cell for tuning Product Name as word wrap<br/></span>
<span style={ { color: 'red' } }>
<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>
</span>
<ColumnWordWrapTable />
</div>
</div>
</div>
<div className='col-md-offset-1 col-md-8'>
<div className='panel panel-default'>
<div className='panel-heading'>Column Title Example</div>
Expand Down

0 comments on commit 0dfded4

Please sign in to comment.