Hi,
The filters in the table is case sensitive. I've gone through the documentation but couldn't find anything on how to change it to not being case sensitive. Any suggestions??
Thanks in advance.
Have you taken a look at the Filtering section of the Readme?
If you want to set the filters on the whole table you can use the defaultFilterMethod or you can set each column individually with the filterMethod. The Custom Filtering example is a good reference as well.
@yolohello12 yolohello12
https://github.com/tannerlinsley/react-table/blob/bc7005db9993df2a38c3c04024c9c49638dc5125/src/defaultProps.js#L25:
defaultFilterMethod: (filter, row, column) => {
const id = filter.pivotId || filter.id
return row[id] !== undefined ? String(row[id]).startsWith(filter.value) : true
},
```es6
filterMethod = (filter, row, column) => {
const id = filter.pivotId || filter.id
return row[id] !== undefined ? String(row[id].toLowerCase()).startsWith(filter.value.toLowerCase()) : true
},
```jsx
<Table
defaultFilterMethod={this.filterMethod}
@a-x- That did the trick, thanks a lot.
filterMethod = (filter, row, column) => { const id = filter.pivotId || filter.id return row[id] !== undefined ? String(row[id].toLowerCase()).startsWith(filter.value.toLowerCase()) : true }
I suggest applying .toLowerCase() after String(row[id])
as in String(row[id]).toLowerCase().startsWith, to make sure data in row[id] is actually a string, and that toLowerCase() exists as well.
Becomes:
filterMethod = (filter, row, column) => {
const id = filter.pivotId || filter.id
return row[id] !== undefined ? String(row[id].toLowerCase()).startsWith(filter.value.toLowerCase()) : true
}
Most helpful comment
@yolohello12 yolohello12
https://github.com/tannerlinsley/react-table/blob/bc7005db9993df2a38c3c04024c9c49638dc5125/src/defaultProps.js#L25:
```es6
filterMethod = (filter, row, column) => {
const id = filter.pivotId || filter.id
return row[id] !== undefined ? String(row[id].toLowerCase()).startsWith(filter.value.toLowerCase()) : true
},