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

[DataGrid] Distinguish removed filter in onFilterModelChange #1803

Closed
2 tasks done
ThomasJanUta opened this issue May 31, 2021 · 2 comments · Fixed by #4938
Closed
2 tasks done

[DataGrid] Distinguish removed filter in onFilterModelChange #1803

ThomasJanUta opened this issue May 31, 2021 · 2 comments · Fixed by #4938
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! dx Related to developers' experience feature: Filtering Related to the data grid Filtering feature new feature New feature or request

Comments

@ThomasJanUta
Copy link

ThomasJanUta commented May 31, 2021

When removing a filter with the "x" in the filter panel, a callback "onFilterModelDelete" is triggered. Please add a prop to the XGrid API.
1

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have looked at the code regarding the filter panel.

Summary 💡

Similar to onFilterModelChange a callback is triggered with the deleted filter model item { columnField: 'commodity', operatorValue: 'contains', value: 'rice' } as a prop type.
In contrast to onFilterModelChange, it can be clearly distinguished which filter model triggered the callback.

Motivation 🔦

2

In my project I have additional filters that are separate from the filter panel. The filters are managed separately from XGrid's filter model. I was successful aligning changes with the onFilterModelChange event. However, removing a filter in the panel cannot be clearly distinguised in the onFilterModelChange event. I ended up getting infinite loops, not getting the right filter model, or not being able to distinguish between deletions and value changes.

Contribute

I might be able to get this done myself and add this as a pull request. I was not successful finding out how the onFilterModelChange is triggered and how it is passed as a prop in the API. Hints with links to the code in regard to the implementation would help me, too.

Alternative implementation

I found a custom component in Material UI's storybook. However it is not documented and there are styling errors. How can I access the code for these stories?
If I could customize the filter panel directly I would not need additional filters that are separate from the filter panel.
Regarding my use case, I would not know how replace the selection with checkboxes or any other component or connect it to XGrid's filter model.
For my use case, the deletion event would suffice.

Order id 💳

Order '#24683'

@ThomasJanUta ThomasJanUta added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 31, 2021
@dtassone
Copy link
Member

TBH, I do not see much value in adding onFilterModelDelete property. You can just use onFilterModelChange, keep the model in state, and when you delete a filter you can compare the model in state with the model in params, and see which filters were removed.

@oliviertassinari
Copy link
Member

oliviertassinari commented May 31, 2021

removing a filter in the panel cannot be clearly distinguised in the onFilterModelChange event.

See mui/material-ui#19959 for how we solve the exact same problem in the Autocomplete. We added a reason argument and which item in the state was changed.

I believe we can do the same here.

@oliviertassinari oliviertassinari changed the title Add event "onFilterModelDelete" when removing a filter [DataGrid] Add event "onFilterModelDelete" when removing a filter May 31, 2021
@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 31, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] Add event "onFilterModelDelete" when removing a filter [DataGrid] Clearly distinguise removed filter in onFilterModelChange May 31, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] Clearly distinguise removed filter in onFilterModelChange [DataGrid] Distinguise removed filter in onFilterModelChange May 31, 2021
@ZeeshanTamboli ZeeshanTamboli changed the title [DataGrid] Distinguise removed filter in onFilterModelChange [DataGrid] Distinguish removed filter in onFilterModelChange Jun 2, 2021
@oliviertassinari oliviertassinari added the feature: Filtering Related to the data grid Filtering feature label Jan 29, 2022
@m4theushw m4theushw self-assigned this May 19, 2022
@joserodolfofreitas joserodolfofreitas added the dx Related to developers' experience label May 20, 2022
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! dx Related to developers' experience feature: Filtering Related to the data grid Filtering feature new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants