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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const columns = [{
}, {
dataField: 'name',
text: 'Product Name',
filter: textFilter()
filter: textFilter({ caseSensitive: true })
}, {
dataField: 'price',
text: 'Product Price',
Expand All @@ -38,7 +38,7 @@ const columns = [{
}, {
dataField: 'name',
text: 'Product Name',
filter: textFilter()
filter: textFilter({ caseSensitive: true })
}, {
dataField: 'price',
text: 'Product Price',
Expand Down
16 changes: 13 additions & 3 deletions packages/react-bootstrap-table2-filter/src/components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ class TextFilter extends Component {
}

render() {
const { placeholder, column: { text }, style, className, onFilter, ...rest } = this.props;
const {
placeholder,
column: { text },
style,
className,
onFilter,
caseSensitive,
...rest
} = this.props;
// stopPropagation for onClick event is try to prevent sort was triggered.
return (
<input
Expand All @@ -95,12 +103,14 @@ TextFilter.propTypes = {
delay: PropTypes.number,
placeholder: PropTypes.string,
style: PropTypes.object,
className: PropTypes.string
className: PropTypes.string,
caseSensitive: PropTypes.bool
};

TextFilter.defaultProps = {
delay: FILTER_DELAY,
defaultValue: ''
defaultValue: '',
caseSensitive: false
};


Expand Down
7 changes: 5 additions & 2 deletions packages/react-bootstrap-table2-filter/src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LIKE, EQ } from './comparison';
export const filterByText = _ => (
data,
dataField,
{ filterVal, comparator = LIKE },
{ filterVal, comparator = LIKE, caseSensitive },
customFilterValue
) =>
data.filter((row) => {
Expand All @@ -16,7 +16,10 @@ export const filterByText = _ => (
if (comparator === EQ) {
return cellStr === filterVal;
}
return cellStr.indexOf(filterVal) > -1;
if (caseSensitive) {
return cellStr.toLocaleUpperCase().includes(filterVal.toLocaleUpperCase());
}
return cellStr.includes(filterVal);
});

export const filterFactory = _ => (filterType) => {
Expand Down
7 changes: 5 additions & 2 deletions packages/react-bootstrap-table2-filter/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export default (Base, {
delete currFilters[dataField];
} else {
// select default comparator is EQ, others are LIKE
const { comparator = (filterType === FILTER_TYPE.SELECT ? EQ : LIKE) } = filter.props;
currFilters[dataField] = { filterVal, filterType, comparator };
const {
comparator = (filterType === FILTER_TYPE.SELECT ? EQ : LIKE),
caseSensitive = false
} = filter.props;
currFilters[dataField] = { filterVal, filterType, comparator, caseSensitive };
}
store.filters = currFilters;

Expand Down