Skip to content

Commit

Permalink
example for #1276
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed May 6, 2017
1 parent b15475a commit d80460b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/js/selection/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 SelectAllWithFilterTable from './select-filter-table';
import SelectAll from './all-select';

class Demo extends React.Component {
Expand Down Expand Up @@ -157,6 +158,17 @@ 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'>Select All Behavior with Filter/Search</div>
<div className='panel-body'>
<h5>Source in select-filter-table.js</h5>
<span>Configure <code>selectRow.onlyUnselectVisible</code> and observer the behavior for unselect all.</span>
<span>Also check <a href='https://github.com/AllenFang/react-bootstrap-table/issues/1276' target='_blank'>#1276</a></span>
<SelectAllWithFilterTable />
</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>
Expand Down
37 changes: 37 additions & 0 deletions examples/js/selection/select-filter-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(23);

const selectRowProp = {
mode: 'checkbox',
onlyUnselectVisible: true // Particular for unselect all case, it will unselect visible rows.
};

export default class SelectAllWithFilterTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp } search>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price' filter={ { type: 'TextFilter', delay: 500 } }>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}

0 comments on commit d80460b

Please sign in to comment.