Skip to content
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] Please add edit example for treedata #15420

Open
Tracked by #9328
entaildevops opened this issue Nov 14, 2024 · 4 comments
Open
Tracked by #9328

[data grid] Please add edit example for treedata #15420

entaildevops opened this issue Nov 14, 2024 · 4 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Editing Related to the data grid Editing feature feature: Tree data Related to the data grid Tree data feature recipe support: docs-feedback Feedback from documentation page

Comments

@entaildevops
Copy link

entaildevops commented Nov 14, 2024

Related page

https://mui.com/x/react-data-grid/tree-data/

Kind of issue

Missing information

Issue description

It is currently quite unclear how row editing should be accomplished properly with treedata. If you the full featured crud example is modified to use treedata, the editing works - BUT: every edit causes the row to collapse, which is very bad UX. The collapsing occurs because the example uses processRowUpdate to handle updates. As stated here apiref.current.updateRows() would not cause this. But with a lack of example, it is a bit hard to get grasp on how to do it.

The Full example of treedata should have example also on how to properly edit the rows with decent UX when treedata is present.

Context

No response

Search keywords: treedata

@entaildevops entaildevops added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Nov 14, 2024
@zannager zannager added component: data grid This is the name of the generic UI component, not the React module! feature: Tree data Related to the data grid Tree data feature component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! and removed component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Nov 14, 2024
@michelengelen
Copy link
Member

Hey @entaildevops ... That's a good request.
I'll add this to our umbrella issue to add recipes for specific use cases.
Thanks for raising this.

The normal editing feature works though, so what exactly are you trying to accomplish? If you can explain your use case we might be able to help you with it.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information feature: Editing Related to the data grid Editing feature recipe and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 15, 2024
@michelengelen michelengelen changed the title Please add edit example for treedata [data grid] Please add edit example for treedata Nov 15, 2024
@entaildevops
Copy link
Author

entaildevops commented Nov 15, 2024

Good to hear that you´re going to create more examples, @michelengelen!

However, I was able to solve the problem with collapsing rows: the problem was me using setRows() to update all rows within processRowUpdate, which caused the rows collapsing (just as the docs imply). The solution was to use apiRef.current.updateRows() to update only affected rows instead.

Still, it would be helpful if the treedata example would include editing capabilities.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 15, 2024
@michelengelen
Copy link
Member

Good to hear that you´re going to create more examples, @michelengelen!

However, I was able to solve the problem with collapsing rows: the problem was me using setRows() to update all rows within processRowUpdate, which caused the rows collapsing (just as the docs imply). The solution was to use apiRef.current.updateRows() to update only affected rows instead.

Still, it would be helpful if the treedata example would include editing capabilities.

Glad to hear that you could fix it on your own. I would have been able to point you to that as well if you had provided a reproduction example :P

I'll keep that in mind for the next time.

@mui/xgrid should we maybe encourage the use of updateRows instead of rows in state in the recipes more? Feels like this comes up every now and then!

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 18, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Nov 18, 2024
@entaildevops
Copy link
Author

@mui/xgrid should we maybe encourage the use of updateRows instead of rows in state in the recipes more? Feels like this comes up every now and then!

I agree. People tend to copy/paste examples and go from there, so the "correct" way should be used as much as possible. At least I had been using DataGrid for a good while before I bumped into the fact that setRows() is NOT the recommended way to update your content. Yes, the correct way is is mentioned in the docs, but it is easy to miss I guess =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Editing Related to the data grid Editing feature feature: Tree data Related to the data grid Tree data feature recipe support: docs-feedback Feedback from documentation page
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

3 participants