Comments (8)
Hi there @cherniavskii,
My bad, I kept testing around and forgot to revert the demo back to the bug. Corrected now:
Notice how after firing the columnsChange event (STEP 2) the custom filterModel.items get cleared (STEP 3).
Anecdotically, in my CustomDataGrid I've even gotten to fire columnsChange just by changing the filterModel, without even changing the state of the rows.
Solution / patch
I had to keep on going with my development, so what I ended up doing is to:
- take the filters that use a field not present,
- dinamically add columns with those fields,
- hide those columns through the columnVisibilityModel, and
- disable the column selection functionality from the user.
Expected behavior
I would love to be able to have filters with custom fields (and not have to use a patch), but I feel you guys are on a better position to define what the library should support or not so I'll leave that up to you.
In any case, the options are:
- Not allow custom filters (i.e. filterModel with fields not present in the columns definition). In that case, what I'm reporting is not a bug, but a feature.
- Allow custom filters. In this case, what I'm reporting is indeed a bug or needs a change.
from mui-x.
@cherniavskii gentle ping on this.
from mui-x.
Thanks @apedretti
The reason we only support filtering for the fields that are included in the columns
prop is that we need to know the type
of the field and filter operators available for the field:
Suppose the field is missing in the column definitions. In that case, it's not safe to assume the type, and keeping these filters in the filter model could lead to various inconsistencies in the Data Grid UI - this is why the Data Grid cleans the filter model and removes non-existent fields.
Your current solution to the problem is straightforward and makes sense to me 👍🏻
from mui-x.
Hey @apedretti
Could you clarify the expected behavior? This is what I see in the console:
from mui-x.
Also, could you clarify what is the expected behavior when the filterModel
includes items referring to the non-existent columns?
from mui-x.
Here's a demo if anyone else has a similar use case: https://codesandbox.io/p/sandbox/summer-frost-lwsqyt?file=%2Fsrc%2FDemo.tsx%3A94%2C53
But I have to admit that when filtering by hidden fields, it's not clear why specific rows pass the filtering while others don't.
I think this is not great in terms of UX.
from mui-x.
I think we can close the issue as there's no action for us to take on the Data Grid side.
Thanks for your feedback!
from mui-x.
Thanks a lot @cherniavskii
from mui-x.
Related Issues (20)
- [pickers] Allow to refuse ranges that contains at least one disabled date HOT 5
- Move focus up after an edit when shift enter is pressed
- [pickers] Enhancing User Experience: Introducing Month and Year Selection in Date-Pickers HOT 5
- [TreeView][ESM] package exports are incorrect HOT 4
- Make Loading overlay states change based on data HOT 6
- [pickers] Ensuring Comprehensive Validation for Date and DateTime Range Fields HOT 2
- [charts] Axis min/max does not allow dynamic rescaling of the other Axis when that axis has no min/max set HOT 6
- [pickers] Ineffective Date and Time Validation Despite minTime, maxTime, and disableIgnoringDatePartForTimeValidation Settings HOT 2
- [data grid] Dynamic Aggregation Position HOT 7
- [How to get column widths exact on resize within detail panel based on Data Grid columns] HOT 2
- [data grid] Is it possible to have tree data row children open and under that details panel? HOT 9
- [data grid] Same column in different column groups HOT 8
- ThemeProvider not provide Translation keys. HOT 2
- [Data Grid Premium - Cell Copy and paste] Copied content from cell doesnt mantain the sorting set in the data premium grid HOT 3
- [data grid] Copy and Paste content from cell selection doesn't maintain the sorting set HOT 3
- [charts] labels are incorrect in RTL HOT 3
- [data grid] New DataGrid header style not properly passed to header HOT 4
- [data grid] Pressing `Delete` key in a Boolean type cell, the value incorrectly resets to empty string HOT 6
- [data grid premium] Copy and Paste content from cell selection doesnt mantain the sorting set HOT 2
- [data grid] Copy and Paste content from cell selection doesnt mantain the sorting set HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mui-x.