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] How to Avoid column readjustment #12929
Comments
Please provide a minimal reproduction test case with the latest version. This would help a lot 👷. A live example would be perfect. You can find a examples and guides on how to find templates in our docs with which you can provide examples for your specific use-case: Support - Bug reproduction. Thank you! 🙇🏼 |
Hi @michelengelen to reproduce the bug I have to write down the whole code in the Codesplitz and It is over 2k - 3k line of code. Also this issue is currently we are facing in some of our Data Grid is there any better way I can share you the example. |
Can i share the our code implementation how we have defined the Columns for the data Grid will that help ? |
Hey @Shudhanshu-Appnox ... From your video it seems as if it happens when you click the columns button in the toolbar, is that correct? Are you using a controlled column visibility approach? |
@michelengelen |
OK, strange. Some questions:
If possible can you share the implementation in some way? That would make it a lot easier. Thanks! |
@michelengelen Here is the Column Configuration which we are using here Column definitions
Grid ComponentAnd here is the Grid Component
|
Is this a v7 grid? or are you still on v6? |
Did you try updating to v7? I know that we had some problems with flex values on the columns in the past, thats partially why we did that rework. If you haven't tried I would recommend updating (its more future proof as well) and if you need assistance we can help with that as well! |
@michelengelen OK, sure can you let me know how can I update to V7 ? |
we do have a migration guide in the docs: Migration If you need help please feel free to reach out! |
@michelengelen Hi, I have updated the Data Grid Version still the issue is not Resolved. Initially, all the column names were blank after some time the Column Header Name was rendered. So, I thought might be it's due to VisibleFeild model so I commented down that but it still does not resolved. Screen.Recording.2024-05-03.at.12.19.48.PM.mov |
could you try ...
I noticed from your code block that you use quite a lot of literal decalrations in the props. footer: () => (
<GridFooterContainer sx={{ display: "flex" }}>
<div className="flex flex-1">
<GridFooter sx={{ display: { xs: "none", md: "flex " } }} />
</div>
<div className="flex flex-1 justify-end">
<GridFooterServerPagination
pageIndex={pageIndex}
setPageIndex={setPageIndex}
table={apiRef}
totalCount={totalCount}
/>
</div>
</GridFooterContainer>
), should better be const CustomGridFooter = () => (
<GridFooterContainer sx={{ display: "flex" }}>
<div className="flex flex-1">
<GridFooter sx={{ display: { xs: "none", md: "flex " } }} />
</div>
<div className="flex flex-1 justify-end">
<GridFooterServerPagination
pageIndex={pageIndex}
setPageIndex={setPageIndex}
table={apiRef}
totalCount={totalCount}
/>
</div>
</GridFooterContainer>
)
...
footer: CustomGridFooter, // <-- in slots and similar. This will prevent a few unwanted rerenders. The custom components can also be memoized when parts of it are unstable. |
Also, I have added GridFooter as a Slot but still there is no Effect on the behaviour. |
Interesting... that leaves only one last possibility: Do you fetch header definitions (names, etc.) from the server? It looks as if the header does get rendered initially, but without content. A few other things to test:
As it stands I haven't seen anything like that before. @MBilalShafi would you have a striking idea here? |
@michelengelen By commenting the Flex 1 in the column definition the issue has been resolved but it affects the columns auto adjustment. Is there any other workaround for it?
|
I am not that familiar with the header rendering and autosizing. @romgrk or @MBilalShafi might have a better idea. |
@michelengelen I have fixed the bug, the reason this bug was produced was how i was passing the data set to the DATA GRID by destructing. |
Great that you did find the solution for this. Just goes to say that the more acurate the reproduction or code examples are the easier it would have been spotted. :P |
@Shudhanshu-Appnox: 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
Whenever the component rerenders the columns are Re-Adjusting can anyone hepl me on how to avoid this ?
Screen.Recording.2024-04-27.at.2.25.33.PM.mov
Your environment
`npx @mui/envinfo`
Search keywords: Data Grid
Order ID: 83077
The text was updated successfully, but these errors were encountered: