Skip to content

Commit c277c81

Browse files
committed
fix #1007
1 parent ec4864d commit c277c81

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/react-bootstrap-table2-example/examples/column-filter/custom-filter-logic.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import BootstrapTable from 'react-bootstrap-table-next';
1212
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
1313
1414
class Table extends React.Component {
15-
filterByPrice = filterVal =>
16-
products.filter(product => product.price == filterVal);
15+
filterByPrice = (filterVal) => {
16+
if (filterVal) {
17+
return products.filter(product => product.price == filterVal);
18+
}
19+
return products;
20+
}
1721
1822
render() {
1923
const columns = [{
@@ -46,8 +50,12 @@ class Table extends React.Component {
4650
`;
4751

4852
export default class Table extends React.Component {
49-
filterByPrice = filterVal =>
50-
products.filter(product => product.price == filterVal);
53+
filterByPrice = (filterVal) => {
54+
if (filterVal) {
55+
return products.filter(product => product.price == filterVal);
56+
}
57+
return products;
58+
}
5159

5260
render() {
5361
const columns = [{
@@ -67,7 +75,7 @@ export default class Table extends React.Component {
6775

6876
return (
6977
<div>
70-
<h2>Implement a eq filter on product price column</h2>
78+
<h2>Implement Custom Filter</h2>
7179
<BootstrapTable
7280
keyField="id"
7381
data={ products }

0 commit comments

Comments
 (0)