Skip to content

Manual Server-Side Column Filtering with client side global filter #230

Answered by ohmycode
ohmycode asked this question in Q&A
Discussion options

You must be logged in to vote

I just found a way that works for me, leave it here in case it serves somebody else:

const [globalFilter, setGlobalFilter] = useState("")
const searchTerm = String(globalFilter).toLowerCase();
const table = useMantineReactTable({
    data: myData.filter((item => columns.some((col) => (typeof col.enableGlobalFilter === 'undefined' || col.enableGlobalFilter === true) && String(item[col.accessorKey]).toLowerCase().includes(searchTerm))));
    manualFiltering: true,
    onGlobalFilterChange: (s) => {
        return setGlobalFilter(s);
    },
    state: {
        globalFilter
    },
    ...
});

the data.filter() function is a custom implementation for the client side filtering, which looks if …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ohmycode
Comment options

@alessandrojcm
Comment options

@ohmycode
Comment options

Answer selected by ohmycode
@alessandrojcm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants