Replies: 1 comment
-
In v8 you can create custom filter function that accepts complex object/array of many filter functions as filterValue and inside that function you can call filter functions according to object/array you provided. const filtersMap = {
between: (row, columnId, filterValue, addMeta) => { ... },
moreThan: (row, columnId, filterValue, addMeta) => { ... }
}
type ComplexFilterValue {
[filterFnName: string]: any
}
const complexFilterFn: FilterFn<any> = function (
row,
columnId,
filterValue,
addMeta
) {
const filterConfig = filterValue as ComplexFilterValue
return Object.entries(filterConfig).every(([filterFnName, filterFnValue]) => filtersMap[filterFnName](row, columnId, filterFnValue, addMeta))
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create an interface in which the user could choose a filtering function (for example, between, more than, etc.), as well as apply several filter values to a column (at least with one, but preferably with different functions).
Is it possible?
I'm trying to recreate the columns and replace the filterFns when the user changes the function in interface, but the filter is not applied
I found some examples for 7 version but nothing for 8
https://codesandbox.io/s/react-table-datagrid-eojw8?file=/src/Components/ReactTable/index.js
https://stackblitz.com/edit/react-ts-qj2sop?file=App.tsx,use-set-filter-type.tsx
Beta Was this translation helpful? Give feedback.
All reactions