Skip to content

Commit

Permalink
example for #979
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Jan 24, 2017
1 parent 6e52226 commit 7b84f36
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/js/selection/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import RowClickTable from './row-click-table';
import OnlySelectedTable from './only-show-selected-table';
import ExternallyManagedSelection from './externally-managed-selection';
import CustomMultiSelectTable from './custom-multi-select-table';
import SelectionColumnWidthTable from './selection-column-width-table';
import SelectAll from './all-select';

class Demo extends React.Component {
Expand Down Expand Up @@ -146,6 +147,15 @@ 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'>Configure Selection Column Width</div>
<div className='panel-body'>
<h5>Source in selection-column-width-table.js</h5>
<SelectionColumnWidthTable />
</div>
</div>
</div>
</div>
);
}
Expand Down
37 changes: 37 additions & 0 deletions examples/js/selection/selection-column-width-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* 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: 'Item name ' + id,
price: 2100 + i
});
}
}

addProducts(5);

const selectRowProp = {
mode: 'checkbox',
columnWidth: '60px'
};

export default class SelectionColumnWidthTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}

0 comments on commit 7b84f36

Please sign in to comment.