Stack Overflow Asked by nassuncao on December 1, 2021
I’m using [email protected], [email protected] and [email protected], to create a table with out of the box server side pagination and filtering.
The pagination is working fine but I’m having some difficulties with the filtering. I have two default text filters that filter correctly (they get the correct info from the server), but I’m experiencing strange behaviours:
For the filtering, I’m using the DefaultColumnFilter that React-Table offers:
function DefaultColumnFilter({ column: { filterValue, setFilter, id } }) {
return (
<input
value={filterValue || ""}
onChange={e => {
setFilter(e.target.value || undefined)
}}
placeholder={`Rechercher ...`}
/>
)
}
So, my questions are:
I’ve created a sandbox with the relevant code here: https://codesandbox.io/s/mystifying-shape-3tbn7
We finally understood the problem. It was not related with react-table. React-table is perfectly capable of doing server-side filtering out-of-the-box.
The problem was here. We had:
// Render the UI for your table
if (pageLoading) return <Loading />
pageLoading was activated by filtering, and so we replaced it by:
// Render the UI for your table
if (loading) return <Loading />
We were 'erasing' the HTML of our table every time we used the filters. We were replacing the table by a loading bar '' at that moment.
Now we are using a different variable (loading) that is not activated by filtering. It works like a charm!
Answered by Luis Gouveia on December 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP