Description
I have a simple batch edit feature that allows the user to start dragging down or up from an editable cell, selecting cells as they drag.
This stores the initial value, target field, and GridRow objects for all cells selected. When the user ends dragging, the GridRow objects selected have the value for the target field updated, and gridApi.rowEdit.setRowsDirty(GridRowArray) is called to trigger the save.
This works perfectly. However, I have added a simple Undo function. This tracks the original values of the most recent bulk action, and sets them back to their original value if confirmed.
I am storing the GridRow objects array of the original bulk update via the drag feature. I originally attempted to update these stored GridRow objects, as I did in the initial bulk update, and again calling gridApi.rowEdit.setRowsDirty(GridRowArray). Unfortunately, nothing happens this time around.
I found that I had to take a unique ID that I happen to have as a column in my data, and iterate through the current GridRow array in gridApi.grid.rows, and create a new GridRow array from gridApi.grid.rows that match. Only then will gridApi.rowEdit.setRowsDirty(NewButOldGridRowArray) successfully trigger a save.
I am guessing this may be because, upon saving, rather than the GridRow objects being updated, they are replaced instead breaking the reference? I am unsure, however.
Steps to recreate would be:
- Store GridRow objects in an array, available for use after saving.
- Update a specific column in each GridRows entity.
- Trigger a save by passing the array of GridRows into rowEdit.setRowsDirty()
- After the save is successful, attempt to repeat this process with the original GridRow array from step one.
Expected result: After repeating steps with the stored GridRow array in step 4, another save is triggered and values are updated in the UI-Grid.
Actual Result: Nothing happens
I apologize if I am not utilizing the gridApi properly and am not aware. I have not found any mentions of this elsewhere or see reporting of having this issue here on GitHub.