Skip to content

Commit

Permalink
example for #540
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Aug 9, 2016
1 parent 825ca76 commit 0fdf663
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/js/manipulation/default-search-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint max-len: 0 */
/* eslint no-console: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';


const products = [];

function addProducts(quantity) {
const startId = products.length;
const fruits = [ 'banana', 'apple', 'orange', 'tomato', 'strawberries' ];
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Fruit name is ' + fruits[i],
price: 2100 + i
});
}
}

addProducts(5);

const options = {
defaultSearch: 'banana'
};

export default class SearchTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } search={ true } options={ options }>
<TableHeaderColumn dataField='id' isKey={ true } searchable={ false }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Fruit Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
10 changes: 10 additions & 0 deletions examples/js/manipulation/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SearchClearTable from './search-clear-table';
import SearchFormatTable from './search-format-table';
import DebounceSearchTable from './debounce-search-table';
import CustomButtonTextTable from './custom-btn-text-table';
import DefaultSearchTable from './default-search-table';

class Demo extends React.Component {
render() {
Expand Down Expand Up @@ -89,6 +90,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'>Default Search Table</div>
<div className='panel-body'>
<h5>Source in /examples/js/manipulation/default-search-table.js</h5>
<DefaultSearchTable />
</div>
</div>
</div>
<div className='col-md-offset-1 col-md-8'>
<div className='panel panel-default'>
<div className='panel-heading'>Column Filter Example</div>
Expand Down

0 comments on commit 0fdf663

Please sign in to comment.