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

[data grid] How to get filters value using apiRef? #15696

Closed
achoud444 opened this issue Dec 2, 2024 · 2 comments
Closed

[data grid] How to get filters value using apiRef? #15696

achoud444 opened this issue Dec 2, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability feature: Filtering on header Related to the header filtering (Pro) feature status: waiting for author Issue with insufficient information

Comments

@achoud444
Copy link

achoud444 commented Dec 2, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: (required)

Current behavior

I am using the premium version of DataGrid and have a header filter with a Select component that allows multiple values. You can find the implementation here: link.

Currently, I am storing the selected values in the state, but the issue is that I have to include this state in the useMemo dependency array, which causes unnecessary re-renders of the component and the useMemo hook.

Is there a way to directly use apiRef to retrieve the selected filter values? I am already using apiRef.current.setFilterModel to apply the filter, so I would like something similar to apiRef.current.getFilterModel to access the current selected values without triggering re-renders.

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: How to get filters value using apiRef?

@achoud444 achoud444 added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 2, 2024
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Dec 2, 2024
@michelengelen
Copy link
Member

Hey @achoud444 ... there is no live example to view for us, just a sandbox of a docs demo.

Could you implement what you want to achieve in a minimal way so we can have a look?

Also the problem you are describing is covered in the docs. Just use the controlled filterModel.

@michelengelen michelengelen changed the title How to get filters value using apiRef? [data grid] How to get filters value using apiRef? Dec 3, 2024
@michelengelen michelengelen added status: waiting for author Issue with insufficient information customization: logic Logic customizability feature: Filtering on header Related to the header filtering (Pro) feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer bug 🐛 Something doesn't work labels Dec 3, 2024
Copy link

The issue has been inactive for 7 days and has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability feature: Filtering on header Related to the header filtering (Pro) feature status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants