Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix textFilter() for Internet Explorer (includes() and find() are not…
… supported) (#274) * Fix textFilter() for Internet Explorer 11 - replace includes() with indexOf() !== -1 - replace find() with for loop * Requested changes; more readability with for loop - use .length of the columns instead of the Object.keys()
  • Loading branch information
NixonK authored and AllenFang committed Apr 1, 2018
commit 4501ddb6327fb56deea1473272e498834f9267fb
10 changes: 8 additions & 2 deletions packages/react-bootstrap-table2-filter/src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const filterByText = _ => (
if (caseSensitive) {
return cellStr.includes(filterVal);
}
return cellStr.toLocaleUpperCase().includes(filterVal.toLocaleUpperCase());
return cellStr.toLocaleUpperCase().indexOf(filterVal.toLocaleUpperCase()) !== -1;
});

export const filterByNumber = _ => (
Expand Down Expand Up @@ -106,7 +106,13 @@ export const filters = (store, columns, _) => (currFilters) => {
Object.keys(currFilters).forEach((dataField) => {
const filterObj = currFilters[dataField];
filterFn = factory(filterObj.filterType);
const { filterValue } = columns.find(col => col.dataField === dataField);
let filterValue;
for (let i = 0; i < columns.length; i += 1) {
if (columns[i].dataField === dataField) {
filterValue = columns[i].filterValue;
break;
}
}
result = filterFn(result, dataField, filterObj, filterValue);
});
return result;
Expand Down
9 changes: 7 additions & 2 deletions packages/react-bootstrap-table2/src/sort/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ export default Base =>
}

componentWillReceiveProps(nextProps) {
const sortedColumn = nextProps.columns.find(
column => column.dataField === nextProps.store.sortField);
let sortedColumn;
for (let i = 0; i < nextProps.columns.length; i += 1) {
if (nextProps.columns[i].dataField === nextProps.store.sortField) {
sortedColumn = nextProps.columns[i];
break;
}
}
if (sortedColumn && sortedColumn.sort) {
nextProps.store.sortBy(sortedColumn);
}
Expand Down