I want to access formatted as well as "untouched" data in a custom filter but I was unsuccessful:
accessor: row => {
row.ageFormatted = row.age + " yrs";
return row.age;
},
Cell: row => (
<div style={{ textAlign: "center" }}>
{row.original.ageFormatted}
</div>
),
filterMethod: (filter, row) => {
return (
row.age + "" === filter.value ||
row.ageFormatted.contains(filter.value)
);
}
From my code example in a sandbox: https://codesandbox.io/s/react-table-custom-filtering-j90oh (a fork of the official react-table example for custom filtering).
The user should be able to filter for a number or a string like "3 y".
How can I achieve this?