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] Different field in view and edit mode cell #13103
Comments
Hey @mickbigblue ... this should be possible with using a combination of Let me give this a shot and I'll circle back here. |
OK, I found a solution that might be a good fit for you case: Example I did achieve this with a custom cell renderer, custom edit cell renderer and Let me know what you think! |
Hi @michelengelen. Thanks for your help! I get the Backend-Data in a specific Format like:
My column definition for the grid is this:
So in the grid we have these columns where If I implement your solution according to the demo, the allCPs array
In my current implementation I have a transformator component that takes in the backend data and transforms the separate checkpoint fields into the allCPs array before passing it to the datagrid to render it. Maybe this is my mistake. Maybe I should use valueGetters and valueFormatters for the formatting and presentation. Also I could use an invisible column for the planCP object and pass that as the What do you think? |
Well, you basically only have to adjust the example a bit. Right now there is still the Popper in place. This can be replaced with a simple textfield when only one value should be adjusted. Let me know if this works for you. |
This looks quite good to me. Thanks! I'll need to experiment a little bit with it and will get back to you. |
OK, Thanks for letting us know! 👍🏼 |
So I've tried out some stuff but I have some more conceptiual questions. I'll try to be as thorough as possible. As I said, we get the data from the backend in a certain format. Here's a more complete example:
The REST call gives back the (main) sections array and some auxiliary arrays. These auxiliary arrays are for the presentation layer. If you look at the updated BackendSection interface you will see stuff like So a response for
Now, my question is, where do I transform this data into Rows? I need to get the visible names from the auxiliary arrays and present them in the datagrid. But when the user changes the line, I need to send back the changed ID not the name. So to sum it up: In which format do I supply the data to the datagrid best? And how do I get the data back in a format such that the backend accepts it? I hope this is not too confusing. |
Hey @mickbigblue this is not confusing at all, but slightly out of range for the support, but well ... :P So for the transformation you want to do that before it gets passed to the datagrid. This has to main benefits:
Here is a updated demo Here you can see how that transformation could look like. You could also provide all lines/densities to a singleselect column where you can then select one. But without knowing what you are trying to achieve this is hard to tell. (and, as mentioned already, a bit outside of the support range :P) |
The issue has been inactive for 7 days and has been automatically closed. |
The problem in depth
Background
Our application receives data objects from the backend containing various "checkpoint" fields that are aggregated and displayed in a single column, but these fields are not represented as individual columns. For example, each object includes:
Current Implementation
In the UI, we have an "allCPs" column that displays these checkpoint names concatenated as follows:
When entering edit mode (via double click or an edit action button), the goal is for the user to modify the planCP.name field. However, the edit impacts the entire allCPs field because that's how the column is defined.
I now want to be able to let the user double click (or click the edit action button) and edit the cell in the allCPs column but the change should apply to the planCP.name (in this example "myPlanCPname" field in the object used for that row.
This is my current implementation for the custom cell edit renderer but my change is obviously not used to update planCP.name but the whole allCPs (because that's the field in the column definition).
Question
What is the best practice for configuring a DataGrid column to display aggregated data in view mode but allow editing of a specific, related field within the data object in edit mode? Specifically, we need the edit actions within the "allCPs" column to update the planCP.name field instead of the aggregated allCPs field.
Any guidance or recommendations on how to achieve this behavior would be greatly appreciated.
Thanks in advance!
Mick
Your environment
`npx @mui/envinfo`
Search keywords: editing non column values
Order ID: 80654
The text was updated successfully, but these errors were encountered: