diff --git a/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js b/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js
index f7a0fca..0f92088 100644
--- a/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js
+++ b/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js
@@ -8,9 +8,9 @@ import { productsQualityGenerator } from 'utils/common';
const products = productsQualityGenerator(6);
const selectOptions = [
- { label: 0, value: 'good' },
- { label: 1, value: 'Bad' },
- { label: 2, value: 'unknown' }
+ { value: 0, label: 'good' },
+ { value: 1, label: 'Bad' },
+ { value: 2, label: 'unknown' }
];
const columns = [{
@@ -22,7 +22,7 @@ const columns = [{
}, {
dataField: 'quality',
text: 'Product Quailty',
- formatter: cell => selectOptions.find(opt => opt.label === cell).value,
+ formatter: cell => selectOptions.find(opt => opt.value === cell).label,
filter: selectFilter({
options: selectOptions
})
@@ -33,9 +33,9 @@ import BootstrapTable from 'react-bootstrap-table-next';
import filterFactory, { selectFilter } from 'react-bootstrap-table2-filter';
const selectOptions = [
- { label: 0, value: 'good' },
- { label: 1, value: 'Bad' },
- { label: 2, value: 'unknown' }
+ { value: 0, label: 'good' },
+ { value: 1, label: 'Bad' },
+ { value: 2, label: 'unknown' }
];
const columns = [{
@@ -47,7 +47,7 @@ const columns = [{
}, {
dataField: 'quality',
text: 'Product Quailty',
- formatter: cell => selectOptions.find(opt => opt.label === cell).value,
+ formatter: cell => selectOptions.find(opt => opt.value === cell).label,
filter: selectFilter({
options: selectOptions
})
diff --git a/packages/react-bootstrap-table2-filter/README.md b/packages/react-bootstrap-table2-filter/README.md
index f73b962..b38007e 100644
--- a/packages/react-bootstrap-table2-filter/README.md
+++ b/packages/react-bootstrap-table2-filter/README.md
@@ -119,15 +119,15 @@ const qualityFilter = selectFilter({
```js
const selectOptions = [
- { label: 0, value: 'good' },
- { label: 1, value: 'Bad' },
- { label: 2, value: 'unknown' }
+ { value: 0, label: 'good' },
+ { value: 1, label: 'Bad' },
+ { value: 2, label: 'unknown' }
];
const columns = [
..., {
dataField: 'quality',
text: 'Product Quailty',
- formatter: cell => selectOptions.find(opt => opt.label === cell).value,
+ formatter: cell => selectOptions.find(opt => opt.value === cell).label,
filter: selectFilter({
options: selectOptions
})
diff --git a/packages/react-bootstrap-table2-filter/src/components/select.js b/packages/react-bootstrap-table2-filter/src/components/select.js
index a30e691..973bdb3 100644
--- a/packages/react-bootstrap-table2-filter/src/components/select.js
+++ b/packages/react-bootstrap-table2-filter/src/components/select.js
@@ -9,7 +9,10 @@ import { FILTER_TYPE } from '../const';
function optionsEquals(currOpts, prevOpts) {
if (Array.isArray(currOpts)) {
for (let i = 0; i < currOpts.length; i += 1) {
- if (currOpts[i].label !== prevOpts[i].label) {
+ if (
+ currOpts[i].value !== prevOpts[i].value ||
+ currOpts[i].label !== prevOpts[i].label
+ ) {
return false;
}
}
@@ -86,7 +89,7 @@ class SelectFilter extends Component {
}
if (Array.isArray(options)) {
options.forEach(({ value, label }) =>
- optionTags.push());
+ optionTags.push());
} else {
Object.keys(options).forEach(key =>
optionTags.push()