Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 51fbb1e

Browse files
fix #1324
1 parent 9ca4333 commit 51fbb1e

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

‎packages/react-bootstrap-table2-example/examples/column-filter/filter-hooks.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,26 @@ const columns = [{
4141
})
4242
}];
4343
44-
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
44+
function afterFilter(newResult, newFilters) {
45+
console.log(newResult);
46+
console.log(newFilters);
47+
}
48+
49+
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory({ afterFilter }) } />
4550
`;
4651

52+
function afterFilter(newResult, newFilters) {
53+
console.log(newResult);
54+
console.log(newFilters);
55+
}
56+
4757
export default () => (
4858
<div>
4959
<BootstrapTable
5060
keyField="id"
5161
data={ products }
5262
columns={ columns }
53-
filter={ filterFactory() }
63+
filter={ filterFactory({ afterFilter }) }
5464
/>
5565
<Code>{ sourceCode }</Code>
5666
</div>

‎packages/react-bootstrap-table2-filter/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,28 @@ Default filter is rendered inside the table column header, but you can choose to
361361
filterPosition="bottom"
362362
/>
363363
```
364+
365+
## Configuration
366+
367+
`filterFactory` is a factory function for initializing some internal config. Below is available options for `filterFactory`:
368+
369+
### afterFilter
370+
This hook function will be called with two arguments(new filter result and filter object) when filtering completed.
371+
372+
```js
373+
function afterFilter(newResult, newFilters) {
374+
console.log(newResult);
375+
console.log(newFilters);
376+
}
377+
378+
export default () => (
379+
<div>
380+
<BootstrapTable
381+
keyField="id"
382+
data={ products }
383+
columns={ columns }
384+
filter={ filterFactory({ afterFilter }) }
385+
/>
386+
</div>
387+
);
388+
```

‎packages/react-bootstrap-table2-filter/src/context.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ export default (
9595
}
9696

9797
doFilter(props, ignoreEmitDataChange = false) {
98-
const { dataChangeListener, data, columns } = props;
98+
const { dataChangeListener, data, columns, filter } = props;
9999
const result = filters(data, columns, _)(this.currFilters, this.clearFilters);
100+
if (filter.afterFilter) {
101+
filter.afterFilter(result, this.currFilters);
102+
}
100103
this.data = result;
101104
if (dataChangeListener && !ignoreEmitDataChange) {
102105
this.isEmitDataChange = true;

‎packages/react-bootstrap-table2/src/contexts/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ const withContext = Base =>
302302
{ ...baseProps }
303303
ref={ n => this.filterContext = n }
304304
data={ rootProps.getData() }
305+
filter={ this.props.filter.options || {} }
305306
dataChangeListener={ this.props.dataChangeListener }
306307
>
307308
<this.FilterContext.Consumer>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /