-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 #13202
Comments
Please follow the code example as precisely as possible. The example you gave is incorrect jsx syntax as well and not working at all. This is the code example you gave in a fixed version: import * as React from 'react';
import {
DataGrid,
GridToolbarColumnsButton,
GridToolbarContainer,
GridToolbarFilterButton,
GridToolbarProps
} from "@mui/x-data-grid";
interface CustomToolbarProps extends GridToolbarProps {
loadingState?: boolean;
showCustomMenuButton?: boolean;
rowSelectionModel?: boolean;
setFilterButtonEl?: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;
}
function CustomToolbar ({
showCustomMenuButton = false,
setFilterButtonEl,
}: CustomToolbarProps) {
return (
<GridToolbarContainer>
<GridToolbarColumnsButton />
<GridToolbarFilterButton
ref={setFilterButtonEl} />
</GridToolbarContainer>
);
}
export default function() {
const [filterButtonEl, setFilterButtonEl] = React.useState<HTMLButtonElement | null>(null);
return (
<DataGrid
rows={[]}
columns={[]}
slots={{
toolbar: CustomToolbar
}}
slotProps={{
panel: {
anchorEl: filterButtonEl,
},
toolbar: {
setFilterButtonEl,
showCustomMenuButton: true,
rowSelectionModel: false,
loadingState: false,
},
columnsPanel: {
sx: {
[`& .MuiDataGrid-columnsManagement > label:first-child, & .MuiDataGrid-columnsManagement > label:last-child`]:
{
display: '',
},
},
},
}}
/>
)
} It is important that the component passed into the slot is either memoized or a static component, not a function literal. As a tip for the next time: Providing a live code example really helps in fixing the problem. |
Reference to the other issue #13186 |
When the provided solution works please feel free to close the issue @mahammahmood |
@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. |
The problem in depth
When i implement the solution you guys provided 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.
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: