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 f54c1f7

Browse files
display filter condition correctly and make sure text filter to be String
1 parent 3775345 commit f54c1f7

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const columns = [{
2222
text: 'Product Name'
2323
}, {
2424
dataField: 'quality',
25-
text: 'Product Quailty',
25+
text: 'Product Quality',
2626
formatter: cell => selectOptions[cell],
2727
filter: selectFilter({
2828
options: selectOptions,
@@ -34,7 +34,7 @@ const columns = [{
3434
}];
3535

3636
const handleClick = () => {
37-
qualityFilter('0');
37+
qualityFilter(0);
3838
};
3939

4040
const sourceCode = `\
@@ -57,7 +57,7 @@ const columns = [{
5757
text: 'Product Name'
5858
}, {
5959
dataField: 'quality',
60-
text: 'Product Quailty',
60+
text: 'Product Quality',
6161
formatter: cell => selectOptions[cell],
6262
filter: selectFilter({
6363
options: selectOptions,
@@ -69,7 +69,7 @@ const columns = [{
6969
}];
7070
7171
const handleClick = () => {
72-
qualityFilter('0');
72+
qualityFilter(0);
7373
};
7474
7575
export default () => (

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const columns = [{
2727
}];
2828

2929
const handleClick = () => {
30-
nameFilter('0');
30+
nameFilter(0);
3131
};
3232

3333
const sourceCode = `\
@@ -55,7 +55,7 @@ const columns = [{
5555
}];
5656
5757
const handleClick = () => {
58-
nameFilter('0');
58+
nameFilter(0);
5959
};
6060
6161
export default () => (

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class NumberFilter extends Component {
4242
if (getFilter) {
4343
getFilter((filterVal) => {
4444
this.setState(() => ({ isSelected: (filterVal !== '') }));
45+
this.numberFilterComparator.value = filterVal.comparator;
46+
this.numberFilter.value = filterVal.number;
47+
4548
onFilter(column, FILTER_TYPE.NUMBER)({
4649
number: filterVal.number,
4750
comparator: filterVal.comparator

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class SelectFilter extends Component {
3636
if (getFilter) {
3737
getFilter((filterVal) => {
3838
this.setState(() => ({ isSelected: filterVal !== '' }));
39+
this.selectInput.value = filterVal;
40+
3941
onFilter(column, FILTER_TYPE.SELECT)(filterVal);
4042
});
4143
}

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,37 @@ import { LIKE, EQ, NE, GT, GE, LT, LE } from './comparison';
66
export const filterByText = _ => (
77
data,
88
dataField,
9-
{ filterVal = '', comparator = LIKE, caseSensitive },
9+
{ filterVal: userInput = '', comparator = LIKE, caseSensitive },
1010
customFilterValue
11-
) =>
12-
data.filter((row) => {
13-
let cell = _.get(row, dataField);
14-
if (customFilterValue) {
15-
cell = customFilterValue(cell, row);
16-
}
17-
const cellStr = _.isDefined(cell) ? cell.toString() : '';
18-
if (comparator === EQ) {
19-
return cellStr === filterVal;
20-
}
21-
if (caseSensitive) {
22-
return cellStr.includes(filterVal);
23-
}
24-
return cellStr.toLocaleUpperCase().indexOf(filterVal.toLocaleUpperCase()) !== -1;
25-
});
11+
) => {
12+
// make sure filter value to be a string
13+
const filterVal = userInput.toString();
14+
15+
return (
16+
data.filter((row) => {
17+
let cell = _.get(row, dataField);
18+
if (customFilterValue) {
19+
cell = customFilterValue(cell, row);
20+
}
21+
const cellStr = _.isDefined(cell) ? cell.toString() : '';
22+
if (comparator === EQ) {
23+
return cellStr === filterVal;
24+
}
25+
if (caseSensitive) {
26+
return cellStr.includes(filterVal);
27+
}
28+
29+
return cellStr.toLocaleUpperCase().indexOf(filterVal.toLocaleUpperCase()) !== -1;
30+
})
31+
);
32+
};
2633

2734
export const filterByNumber = _ => (
2835
data,
2936
dataField,
3037
{ filterVal: { comparator, number } },
3138
customFilterValue
32-
) =>
39+
) =>(
3340
data.filter((row) => {
3441
if (number === '' || !comparator) return true;
3542
let valid = true;
@@ -81,7 +88,8 @@ export const filterByNumber = _ => (
8188
}
8289
}
8390
return valid;
84-
});
91+
})
92+
);
8593

8694
export const filterFactory = _ => (filterType) => {
8795
let filterFn;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default (Base, {
6363
} = filter.props;
6464
currFilters[dataField] = { filterVal, filterType, comparator, caseSensitive };
6565
}
66+
6667
store.filters = currFilters;
6768

6869
if (this.isRemoteFiltering() || this.isRemotePagination()) {

0 commit comments

Comments
(0)

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