You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a data grid with externally state-managed filterModel, opening the filter modal and adding a new filter (with "and") unsets the initial filter state.
Setting a property id (of any value) on the initial filter item seems to resolve the issue, but this is not documented and seems surprising.
{
items: [
{
columnField: "commodity",
operatorValue: "contains",
value: "rice",
id: 123 // <- adding this field resolves the issue
}
]
}
Screen.Recording.2021-09-29.at.09.52.41.mov
Expected behavior 🤔
Initial filter state should be maintained, or requirement for id property should be documented.
As you said, if you have multiple filters, they should have an ID.
Here is the exact logic :
if(props.filterModel!==undefined&&props.filterModel.items.length>1){consthasItemsWithoutIds=props.filterModel.items.find((item)=>item.id==null);if(hasItemsWithoutIds){thrownewError("The 'id' field is required on filterModel.items when you use multiple filters.",);}}
flaviendelangle
changed the title
Initial filter state removed when a filter is added
[docs] Missing explanations about the "id" field in the GridFilterModel
Sep 29, 2021
Duplicates
Latest version
Current behavior 😯
When creating a data grid with externally state-managed
filterModel
, opening the filter modal and adding a new filter (with "and") unsets the initial filter state.Setting a property
id
(of any value) on the initial filter item seems to resolve the issue, but this is not documented and seems surprising.Screen.Recording.2021-09-29.at.09.52.41.mov
Expected behavior 🤔
Initial filter state should be maintained, or requirement for
id
property should be documented.Steps to reproduce 🕹
Reproduced in CodeSandbox
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: