How can I create a number range filter in react table v7? Here is my relevant column definition, and filter function.
// The Filter function
import { Box, Input } from '@mui/material';
const NumberFilter = ({ column, data }) => {
const { filterValue = [], setFilter } = column;
console.log('filterValue: ' + filterValue);
return (
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Input
placeholder="Min"
value={filterValue[0] || ''}
type="number"
onChange={(e) => {
setFilter([e.target.value || undefined, filterValue[1]]);
}}
/>
<Input
placeholder="Max"
value={filterValue[1] || ''}
type="number"
onChange={(e) => {
setFilter([filterValue[0], e.target.value || undefined]);
}}
/>{' '}
</Box>
);
};
export default NumberFilter;
// The column definition...
{
Header: 'Pant Size',
accessor: 'pant-size',
Filter: NumberFilter,
filter: 'isNumberRange',
filterValue: [0, 10],
Cell: ({ value}) => value);
}
This does not work. Instead of filtering all rows that have a value within the range of min and max, the column seems to be doing text matching, which is the default.
I think my issue is that there are various options for the filter parameter. For example, 'text' and 'exact'. I read somewhere that there is an option for numeric ranges and it was "isNumberRange". This clearly is incorrect. Is there another option? Does anyone know where this documentation lives?