Skip to content
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

Open
2 tasks done
Hassanabdelqader opened this issue Jan 26, 2025 · 1 comment
Open
2 tasks done

filter is not working #5889

Hassanabdelqader opened this issue Jan 26, 2025 · 1 comment

Comments

@Hassanabdelqader
Copy link

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

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@viktorhex
Copy link

viktorhex commented Jan 29, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants