-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter is not working #5889
Comments
Tip: Consider transforming a cell's value into a string before integrating with TanStack. Similar issue: I've found that even though my array of strings was transformed into a single string via the ColumnDef's cell field, my filter logic was not working for that data. My filter logic worked for any ColumnDef that I defined as type string. Solution: To resolve this, I transformed my data into a string and defined my TanStack table column cell data type as string. |
THANK YOU!!!!!!! If it weren't for you I would be swimming in shit for next 12 hours. I have no idea why this isn't documented anywhere!! I would call column.setFilter and updater would just spit out [] as columnFilters
I will drop some keywords to save people in future: |
TanStack Table version
pnpm ^8.20.6
Framework/Library version
next ^15.1.3
Describe the bug and the steps to reproduce it
When implementing manual server-side pagination, an issue arises when applying a filter while not on the first page. The pagination resets as expected, but the filter value does not update correctly. However, when on the first page, the filter functions as intended.
The problem seems to stem from the setFilterValue function provided by the column. This function appears to perform two actions simultaneously: resetting the pagination and setting the filter value. Due to this simultaneous operation, a conflict occurs, preventing the filter from applying correctly.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
<FloatingLabelInput type={column.inputType ?? 'text'} label={column.label} value={(table.getColumn(String(column.value))?.getFilterValue() as string) || ''} onChange={(event) => { console.log({ event }); setTimeout(() => { table.resetPagination(); }, 0); table.getColumn(String(column.value))?.setFilterValue(event.target.value); }} classNameLabel="text-sm" className="h-12 w-full" showClearIcon={ column.showClearIcon && (table.getColumn(String(column.value))?.getFilterValue() as string) ? ( ) : undefined } />
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: