Skip to content

Commit b54f84a

Browse files
committed
add debounce-search-table example
1 parent 8dc6436 commit b54f84a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
const fruits = [ 'banana', 'apple', 'orange', 'tomato', 'strawberries', 'cherries' ];
11+
for (let i = 0; i < quantity; i++) {
12+
const id = startId + i;
13+
products.push({
14+
id: id,
15+
name: 'Fruits: ' + fruits[i] + ' and ' + fruits[i + 1],
16+
price: 2100 + i
17+
});
18+
}
19+
}
20+
21+
addProducts(5);
22+
23+
24+
export default class DebounceSearchTable extends React.Component {
25+
render() {
26+
const options = {
27+
searchDelayTime: 500
28+
};
29+
30+
return (
31+
<BootstrapTable data={ products } search={ true } multiColumnSearch={ true } options={ options } searchPlaceholder='Search delay 500ms'>
32+
<TableHeaderColumn dataField='id' isKey={ true } searchable={ false }>Product ID</TableHeaderColumn>
33+
<TableHeaderColumn dataField='name'>Fruits</TableHeaderColumn>
34+
<TableHeaderColumn dataField='price'>Price</TableHeaderColumn>
35+
</BootstrapTable>
36+
);
37+
}
38+
}

examples/js/manipulation/demo.js

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import MultiSearchTable from './multi-search-table';
88
import ExportCSVTable from './export-csv-table';
99
import DeleteRowCustomComfirmTable from './del-row-custom-confirm';
1010
import SearchClearTable from './search-clear-table';
11+
import DebounceSearchTable from './debounce-search-table';
1112

1213
class Demo extends React.Component {
1314
render() {
@@ -62,6 +63,16 @@ class Demo extends React.Component {
6263
</div>
6364
</div>
6465
</div>
66+
<div className='col-md-offset-1 col-md-8'>
67+
<div className='panel panel-default'>
68+
<div className='panel-heading'>Debounce Search Table Example(Use searchDelayTime props to set your search delay time)</div>
69+
<div className='panel-body'>
70+
<h5>Source in /examples/js/manipulation/debounce-search-table.js</h5>
71+
<h5>use <code>searchDelayTime</code> for <code>options</code> object to set delay time in search input and default is 0.</h5>
72+
<DebounceSearchTable />
73+
</div>
74+
</div>
75+
</div>
6576
<div className='col-md-offset-1 col-md-8'>
6677
<div className='panel panel-default'>
6778
<div className='panel-heading'>Column Filter Example</div>

0 commit comments

Comments
 (0)