T
TanStack15mo ago
foreign-sapphire

Complex filters

Hi, I have a complex filter (consist of a string - search phrase and a boolean - toggle).
I would like all of the columns to be filtered by default filterFn (I believe includesString) apart from one column that would be filtered by that toggle(it is not simple match of boolean values). How can I handle complex filters from both perspective table state but then also column filtering? Originally I was thinking about something like
const customFilterFn: FilterFn<Item> = useMemo(
() => row => {
return externalToggle ? row.original.property?.value === externalValue;
},
[externalToggle, externalValue]
);

const columns: ColumnDef<Item>[] = useMemo(() => [{
accessorKey: 'property',
...
filterFn: customFilterFn,
}], []),
const customFilterFn: FilterFn<Item> = useMemo(
() => row => {
return externalToggle ? row.original.property?.value === externalValue;
},
[externalToggle, externalValue]
);

const columns: ColumnDef<Item>[] = useMemo(() => [{
accessorKey: 'property',
...
filterFn: customFilterFn,
}], []),
But this doesn't work 🙁
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?