-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] The popover for the GridToolbarFilterButton and GridToolbarColumnsButton should open under their respective button. #13186
Comments
Hey @mahammahmood ... this is possible by anchoring the panel to the filter button instead of the toolbar. Here is the respective code example (with the columns button): import * as React from 'react';
import {
DataGrid,
GridSlots, GridToolbarColumnsButton,
GridToolbarContainer, GridToolbarExportContainer,
GridToolbarFilterButton,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';
const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin'];
interface CustomToolbarProps {
setFilterButtonEl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;
}
function CustomToolbar({ setFilterButtonEl }: CustomToolbarProps) {
return (
<GridToolbarContainer>
<GridToolbarColumnsButton />
<GridToolbarFilterButton ref={setFilterButtonEl} />
</GridToolbarContainer>
);
}
export default function CustomFilterPanelPosition() {
const { data } = useDemoData({
dataSet: 'Employee',
visibleFields: VISIBLE_FIELDS,
rowLength: 100,
});
const [filterButtonEl, setFilterButtonEl] =
React.useState<HTMLButtonElement | null>(null);
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
slots={{
toolbar: CustomToolbar as GridSlots['toolbar'],
}}
slotProps={{
panel: {
anchorEl: filterButtonEl,
},
toolbar: {
setFilterButtonEl,
},
}}
/>
</div>
);
} |
@mahammahmood: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
When i implement this solution i got error on this Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. this is my code. can you please help me to resolve this issue.
|
The problem in depth
The popover for the GridToolbarFilterButton and GridToolbarColumnsButton should open under their respective button. For now both open at the start of the data grid. I'm using Data Grid Pro plan Version 7.
Below is an example of what I want.
Your environment
`npx @mui/envinfo`
Search keywords: Data ,Grid , Pro, GridToolbarFilterButton, GridToolbarColumnsButton, version 7
Order ID: 81584
The text was updated successfully, but these errors were encountered: