Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ You can assign any [HTML Event](https://www.w3schools.com/tags/ref_eventattribut
* onMouseEnter
* onMouseLeave
* onContextMenu
* onAuxClick

```js
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,26 @@ const columns = [{
})
}];

<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
function afterFilter(newResult, newFilters) {
console.log(newResult);
console.log(newFilters);
}

<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory({ afterFilter }) } />
`;

function afterFilter(newResult, newFilters) {
console.log(newResult);
console.log(newFilters);
}

export default () => (
<div>
<BootstrapTable
keyField="id"
data={ products }
columns={ columns }
filter={ filterFactory() }
filter={ filterFactory({ afterFilter }) }
/>
<Code>{ sourceCode }</Code>
</div>
Expand Down
25 changes: 25 additions & 0 deletions packages/react-bootstrap-table2-filter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,28 @@ Default filter is rendered inside the table column header, but you can choose to
filterPosition="bottom"
/>
```

## Configuration

`filterFactory` is a factory function for initializing some internal config. Below is available options for `filterFactory`:

### afterFilter
This hook function will be called with two arguments(new filter result and filter object) when filtering completed.

```js
function afterFilter(newResult, newFilters) {
console.log(newResult);
console.log(newFilters);
}

export default () => (
<div>
<BootstrapTable
keyField="id"
data={ products }
columns={ columns }
filter={ filterFactory({ afterFilter }) }
/>
</div>
);
```
5 changes: 4 additions & 1 deletion packages/react-bootstrap-table2-filter/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ export default (
}

doFilter(props, ignoreEmitDataChange = false) {
const { dataChangeListener, data, columns } = props;
const { dataChangeListener, data, columns, filter } = props;
const result = filters(data, columns, _)(this.currFilters, this.clearFilters);
if (filter.afterFilter) {
filter.afterFilter(result, this.currFilters);
}
this.data = result;
if (dataChangeListener && !ignoreEmitDataChange) {
this.isEmitDataChange = true;
Expand Down
3 changes: 2 additions & 1 deletion packages/react-bootstrap-table2/src/cell-event-delegater.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const events = [
'onDoubleClick',
'onMouseEnter',
'onMouseLeave',
'onContextMenu'
'onContextMenu',
'onAuxClick'
];

export default ExtendBase =>
Expand Down
1 change: 1 addition & 0 deletions packages/react-bootstrap-table2/src/contexts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ const withContext = Base =>
{ ...baseProps }
ref={ n => this.filterContext = n }
data={ rootProps.getData() }
filter={ this.props.filter.options || {} }
dataChangeListener={ this.props.dataChangeListener }
>
<this.FilterContext.Consumer>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-bootstrap-table2/src/row/event-delegater.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const events = [
'onDoubleClick',
'onMouseEnter',
'onMouseLeave',
'onContextMenu'
'onContextMenu',
'onAuxClick'
];

export default ExtendBase =>
Expand Down