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

refactor(react-table): allow conditional filters on useTable #5862

Merged
merged 6 commits into from Apr 24, 2024

Conversation

aliemir
Copy link
Member

@aliemir aliemir commented Apr 18, 2024

useTable hook was ignoring the conditional filters with "and" and "or" operators, causing custom filtering logic inside the table to not work as expected and omitting the filters from the query. This PR enables working with conditional filters and fixes the disappearing filters issue.

To customize the key value of the conditional filter, you can use the filterKey property in the column's meta property. This property will be used as the key for the filter when setting the filter value to the table from @refinedev/core's filter state and when setting the filter value to the filter state from the table.

// An example of how to use the `filterKey` property in the column's `meta` property
const columns: ColumnDef<IPost> = [
  {
    id: "title",
    header: "Title",
    accessorKey: "title",
    meta: {
      // This is optional, if not defined column id will be used as the key
      filterKey: "titleFilter",
      // If operator is not `'eq'` or `'in'`, make sure to set the `filterOperator` property
      filterOperator: "and",
    },
  },
];

Resolves #5856

@aliemir aliemir requested a review from a team as a code owner April 18, 2024 07:06
Copy link

changeset-bot bot commented Apr 18, 2024

🦋 Changeset detected

Latest commit: 13d465a

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

nx-cloud bot commented Apr 18, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 13d465a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 33 targets

Sent with 💌 from NxCloud.

@refine-bot refine-bot temporarily deployed to deploy-preview-mui-5862 April 18, 2024 07:09 Inactive
@aliemir aliemir added this to the May Release milestone Apr 18, 2024
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-5862 April 18, 2024 07:10 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-5862 April 18, 2024 07:25 Inactive
Copy link

cypress bot commented Apr 18, 2024

Passing run #10961 ↗︎

0 178 11 0 Flakiness 0

Details:

Merge b041ee6 into b449b80...
Project: refine Commit: 8e7b26fbcb ℹ️
Status: Passed Duration: 17:51 💡
Started: Apr 18, 2024 7:14 AM Ended: Apr 18, 2024 7:31 AM

Review all test suite changes for PR #5862 ↗︎

@aliemir aliemir changed the base branch from master to releases/may April 24, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants