Filtering column of cells that contain multiple values
Hey, I'm trying to wrap my head around how to filter a column of cells that their data is an array of strings. Each cell is an array of these strings and the same strings can appear in many cells.
I'm following the "Tasks" example from shadcn-ui (https://github.com/shadcn-ui/ui/tree/main/apps/www/app/(app)/examples/tasks), but in this example each cell has a single string value, and the example uses 'getFacetedUniqueValues'
4 Replies
rare-sapphire•2y ago
One approach (and the one I personally use for now), is to define a custom accessor function for the column that converts the array into a string. Other solutions seemed to say you could create a custom filter function that takes the array of strings and parses them to a boolean, but after a few attempts at this I was unsuccessful.
rival-blackOP•2y ago
and then do .includes() on the string you made from the array? if yes where do you call the includes?
rare-sapphire•2y ago
You can try setting the filter func on the column to "stringIncludes". If you have a global filter func defined it should use that if you don't specify a specific filter in the column defs
rival-blackOP•2y ago
What's "stringIncludes"? Do you happen to have a short example on how to achieve that?
Edit: All I had to do is filterFn: 'arrIncludesSome'