Open Ol-Boiko opened 1 year ago
Interesting... that's probably a bug.
But you can easily solve it by always passing the getTreeDataPath
, it will just be ignored when treeData === false
.
And by the way, you should always memoize getTreeDataPath
to avoid re-generating the tree on every render.
Hi flaviendelangle! Thanks for replying! Yeah, agree about memoizing but it was just for simplifying code for an example. I have my getTreeDataPath outside the component. If it is a bug, I hope this will be fixed soon. We need this functionality so much. For now if I switch from Tree Data to simple Grid I'm hiding Group column and disable it in manage column menu, creating fake path for rows, but it takes much efforts for development and automation teams to support all this logic since functionality of Data Grid is overcomplicated and without it
Is there something preventing you from just always passing getTreeDataPath
to your grid?
Previously I received an error when I tried to do in the project. But I used your suggestion and look at it in the different perspective. I cleaned up all the rows while clicking before changing treeData to true and then generated new rows with path and it worked! no Group column in grid and no error!!! https://codesandbox.io/s/data-grid-community-forked-vyktlt?file=/src/App.tsx Thanks a lot!
No problem, we'll keep this issue open to find a proper fix :+1:
Order ID or Support key 💳 (optional)
-
Duplicates
Latest version
The problem in depth 🔍
I want to have possibility to switch between ordinary grid and grid with Tree data like in this example: https://codesandbox.io/s/data-grid-community-forked-yqx6v2?file=/src/App.tsx
if i click to the button "switch Tree"- i'll receive an error "MUI: No getTreeDataPath given."
Thanks in advance
Your environment 🌎
`npx @mui/envinfo`
``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```