Open SpadarShut opened 1 year ago
I am going to take a look at this and try to publish a fix. Can you assign it to me?
After looking at the code and your example, I have found that it may not be a bug.
The filter function only gets called if there is a columnFilters
property in the state object of the table, and this property contains a value that corresponds to the filter value of the column.
Check out the official filters example: https://codesandbox.io/p/sandbox/github/tanstack/table/tree/main/examples/react/filters?embed=1&file=%2Fsrc%2Fmain.tsx%3A352%2C20-352%2C29
Should we close the issue or make changes to the documentation to explain it more clearly?
@arnaugomez thanks for looking into the issue! If this is the intended behaviour, this should be documented I think. And also, what is then the intended way to transform cell value for (global) filters?
@SpadarShut as I see it, the filter function filterFn
is, along with the filters state, the correct way to filter the data.
I plan to issue a PR tomorrow with a proposal to make the documentation clearer on this subject. Thanks for the suggestion 😄
cant find the PR.
Can the global filter use a custom filterFn for a specific column? It doesn't seem like it.
Do I need to define one global filter fn like the fuzzyFilter example, and put a if (columnId === 'my special column")
in it?
And also, what is then the intended way to transform cell value for (global) filters?
Do we have a solution to this?
Any update on this? The documentation for global filters demonstrates using a column's filterFn for global filtering, but when using an inline function for filterFn, the function never gets called.
for global filtering, the table uses the globalFilterFn
@KevinVandy, thanks!
Describe the bug
The
filterFn
prop of a cell definition never gets called. My initial problem was that thefilterFn
'sresolveFilterValue
was never called, but in factfilterFn
is just ignored.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/stupefied-water-3kcw7h?embed=1&file=%2Fsrc%2Fmain.tsx%3A52%2C18
Steps to reproduce
1 Create a basic table with a filterFn prop on a cell 2 Optionally add globalFilter 3 try to search
Expected behavior
As a user I expect filterFn to be called, but returning false from the fn of plain console.log/alert never gets executed.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS
react-table version
8.9.3
TypeScript version
5.1.3
Additional context
No response
Terms & Code of Conduct