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 4dd39ae

Browse files
export onFilter function to allow user to access
1 parent a1477e2 commit 4dd39ae

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

‎packages/react-bootstrap-table2-filter/src/components/number.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint react/require-default-props: 0 */
12
/* eslint no-return-assign: 0 */
23

34
import React, { Component } from 'react';
@@ -30,12 +31,23 @@ class NumberFilter extends Component {
3031
}
3132

3233
componentDidMount() {
33-
const { column, onFilter } = this.props;
34+
const { column, onFilter, getFilterBy } = this.props;
3435
const comparator = this.numberFilterComparator.value;
3536
const number = this.numberFilter.value;
3637
if (comparator && number) {
3738
onFilter(column, FILTER_TYPE.NUMBER)({ number, comparator });
3839
}
40+
41+
// export onFilter function to allow users to access
42+
if (getFilterBy) {
43+
getFilterBy((filterVal) => {
44+
this.setState(() => ({ isSelected: (filterVal !== '') }));
45+
onFilter(column, FILTER_TYPE.NUMBER)({
46+
number: filterVal.number,
47+
comparator: filterVal.comparator
48+
});
49+
});
50+
}
3951
}
4052

4153
componentWillUnmount() {
@@ -224,7 +236,8 @@ NumberFilter.propTypes = {
224236
comparatorStyle: PropTypes.object,
225237
comparatorClassName: PropTypes.string,
226238
numberStyle: PropTypes.object,
227-
numberClassName: PropTypes.string
239+
numberClassName: PropTypes.string,
240+
getFilterBy: PropTypes.func
228241
};
229242

230243
NumberFilter.defaultProps = {

‎packages/react-bootstrap-table2-filter/src/components/select.js‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,19 @@ class SelectFilter extends Component {
2525
}
2626

2727
componentDidMount() {
28+
const { column, onFilter, getFilterBy } = this.props;
29+
2830
const value = this.selectInput.value;
2931
if (value && value !== '') {
30-
this.props.onFilter(this.props.column, FILTER_TYPE.SELECT)(value);
32+
onFilter(column, FILTER_TYPE.SELECT)(value);
33+
}
34+
35+
// export onFilter function to allow users to access
36+
if (getFilterBy) {
37+
getFilterBy((filterVal) => {
38+
this.setState(() => ({ isSelected: filterVal !== '' }));
39+
onFilter(column, FILTER_TYPE.SELECT)(filterVal);
40+
});
3141
}
3242
}
3343

@@ -90,6 +100,7 @@ class SelectFilter extends Component {
90100
comparator,
91101
withoutEmptyOption,
92102
caseSensitive,
103+
getFilterBy,
93104
...rest
94105
} = this.props;
95106

@@ -121,7 +132,8 @@ SelectFilter.propTypes = {
121132
className: PropTypes.string,
122133
withoutEmptyOption: PropTypes.bool,
123134
defaultValue: PropTypes.any,
124-
caseSensitive: PropTypes.bool
135+
caseSensitive: PropTypes.bool,
136+
getFilterBy: PropTypes.func
125137
};
126138

127139
SelectFilter.defaultProps = {

‎packages/react-bootstrap-table2-filter/src/components/text.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ class TextFilter extends Component {
1919
}
2020

2121
componentDidMount() {
22-
const { onFilter } = this.props;
23-
22+
const { onFilter, getFilterBy, column } = this.props;
2423
const defaultValue = this.input.value;
2524

2625
if (defaultValue) {
2726
onFilter(this.props.column, FILTER_TYPE.TEXT)(defaultValue);
2827
}
28+
29+
// export onFilter function to allow users to access
30+
if (getFilterBy) {
31+
getFilterBy((filterVal) => {
32+
this.setState(() => ({ value: filterVal }));
33+
onFilter(column, FILTER_TYPE.TEXT)(filterVal);
34+
});
35+
}
2936
}
3037

3138
componentWillReceiveProps(nextProps) {
@@ -81,6 +88,7 @@ class TextFilter extends Component {
8188
onFilter,
8289
caseSensitive,
8390
defaultValue,
91+
getFilterBy,
8492
...rest
8593
} = this.props;
8694

@@ -110,7 +118,8 @@ TextFilter.propTypes = {
110118
placeholder: PropTypes.string,
111119
style: PropTypes.object,
112120
className: PropTypes.string,
113-
caseSensitive: PropTypes.bool
121+
caseSensitive: PropTypes.bool,
122+
getFilterBy: PropTypes.func
114123
};
115124

116125
TextFilter.defaultProps = {

0 commit comments

Comments
(0)

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