Skip to content

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Aug 28, 2025

@siriwatknp siriwatknp added docs Improvements or additions to the documentation. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Aug 28, 2025
@mui-bot
Copy link

mui-bot commented Aug 28, 2025

Deploy preview: https://deploy-preview-19361--material-ui-x.netlify.app/

Updated pages:

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against d543a4d

@siriwatknp siriwatknp changed the title add filter panel recipe [docs] Add recipe for save and manage filters from the panel Aug 28, 2025
@siriwatknp siriwatknp marked this pull request as ready for review August 28, 2025 09:13
@siriwatknp siriwatknp added the scope: data grid Changes related to the data grid. label Aug 28, 2025
Copy link
Member

@MBilalShafi MBilalShafi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice recipe 😍
Thank you!

Comment on lines 112 to 114
if (!store.activePresetId) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This condition is unlikely to be met, since the button will be disabled on this condition anyways.

Suggested change
if (!store.activePresetId) {
return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function should be independent from UI to avoid error when activePresetId is not present (somehow).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, better to remove it since without activePresetId, the code still function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of a nitpick anyways, feel free to chose whatever feels better. 👍

Comment on lines 108 to 109
const getCurrentFilterModel = () => apiRef.current.state.filter.filterModel;
const hasActiveFilters = () => getCurrentFilterModel().items.length > 0;
Copy link
Member

@MBilalShafi MBilalShafi Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since useGridSelector ensures reactive binding, the value of filterModel will always be latest.

Suggested change
const getCurrentFilterModel = () => apiRef.current.state.filter.filterModel;
const hasActiveFilters = () => getCurrentFilterModel().items.length > 0;
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
const hasActiveFilters = filterModel.items.length > 0;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better

</Typography>
<Stack direction="row" spacing={0.5}>
<Tooltip title="Create new filter">
<IconButton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional improvment: Add button could be made disabled if the current filters are already saved to a Preset, to avoid having multiple presets for exact same filter.
Feel free to drop the suggestion.

}}
>
<Typography variant="subtitle2" sx={{ fontWeight: 'bold' }}>
Saved Filters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clearer to me, wdyt?

Suggested change
Saved Filters
Saved Filter Presets


Create a custom filter panel by wrapping the `GridFilterPanel` component and pass it to the `slots.filterPanel` prop.

In the demo below, the custom component lets users save and manage filters that are persisted in the local storage. You can replace the local storage with a more scalable solution like a server-side database.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the demo below, the custom component lets users save and manage filters that are persisted in the local storage. You can replace the local storage with a more scalable solution like a server-side database.
In the demo below, the custom component allows users to save and manage filters, which are stored in local storage.
For a more scalable approach, you can replace local storage with a server-side database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation. recipe scope: data grid Changes related to the data grid. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Save and restore filtermodels
3 participants