-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filterFromLeafRows table option does not work #4190
Comments
I'm facing same problem, currently worked around it by my own filter function |
I tried using a custom filter function, but it did not help. How did you do it? |
In my case I had many level of subrows, (i.e a subrow could contain more subrows) so even if one subrow matched any level I had to show the the parent rows, I have recurssive function but that's just for my need as I can't tell how many levels deep I'll go, depends on the data. So what my filter function does is it checks the data of current row and returns true if it matches, and then it also looks into subrow data (because subrow data is also part of parent row data), if any subrow matches, it still returns true for parent row Something like this: (It's simplified, I had a recussive function for my subrows) (row, colId, filterValue) => {
if (current_row_matches) {
return true;
}
// If the row doesn't match then add this row to result only if one of its child rows match
if (check_if_this_row_has_subrows) {
const subrowData = row.subrows;
// go through subrow data to find a match (`Array.some()` is very handy here)
const matchFound = subrowData.some(subrow => check_if_this_subrow_matches);
if(matchFound) {
return true;
}
}
// if nor the current row neither any of its subrows matched, exclude this row from result
return false;
}; |
I also have this issue when using |
Same issue here. Not filtering leaf elements though that flag is enabled. |
Describe the bug
The filterFromLeafRows table option seems to not work properly. It is filtering out way more rows than expected.
I used the React Table Expanding example (https://tanstack.com/table/v8/docs/examples/react/expanding) and modfified it, setting the option filterFromLeafRows on the table.
Now when filtering, it seems that the filter value must match both the sub row and the parent row in order for the rows to remain visible. If the filter value matches only the sub row, nothing is displayed (maybe an AND where an OR is needed?).
Your minimal, reproducible example
https://codesandbox.io/s/compassionate-gates-0bpvhg
Steps to reproduce
Expected behavior
As a user, I expect the row "Bonnie" as well as its parent "Jalon" to remain.
Instead, both rows will disappear.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Linux, Firefox
react-table version
v8.2.6
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: