# RadzenGrid - datagrid revert changes on 'cancel' btn

**URL:** <https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449>\
**Category:** Radzen.Blazor Components\
**Created:** [July 29, 2020, 7:17pm UTC](https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449 "2020-07-29T19:17:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_McColgan](https://forum.radzen.com/user_avatar/forum.radzen.com/brian_mccolgan/32/3495_2.png) [@Brian\_McColgan](https://forum.radzen.com/u/Brian_McColgan)\
**Post date:** [July 29, 2020, 7:17pm UTC](https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449/1 "2020-07-29T19:17:53Z")

</div>

Hello,

Firstly a shout out to Radzen and the team, the Blazor components really are excellent!!

Following your example (for the DataGrid) and having some difficulty with Cancel button. The event gets properly dispatched to my handler 'CancelEdit(MyObj mObj)' however having difficulty getting the data to correctly revert for the selected row!

Note: not using scaffolding (Radzen-UI); rather a basic Server-Side RadzenGrid that follows the DataGrid example. The only difference - using a REST API rather than Northwind.

Behavior observed:

- when clicking on 'pencil' to update a row, the editable fields permit me to make a change.
  - back-end correctly updated (REST API) with changes when I click Save
  - if I try 'backing out' of the change (clicking Cancel) -\> the updated data is not reverted.
    - I have to move to another screen (and come back) which presumably re-renders the list/grid.

I have tried saving (restoring) the entity under edit/change at EditRow() inception, and restoring it - on cancel, but that seems not to work either.

I am certain I am doing something incorrectly, hopefully the Radzen guru's can help guide me in the right direction!

Environment: Visual C#, using Radzen.Blazor v2.11.3

Thanks,  
Brian.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [July 30, 2020, 3:40am UTC](https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449/2 "2020-07-30T03:40:30Z")

</div>

Hi Brian,

EF Core can track, save and revert changes - the grid itself cannot. Here is the relevant code from [our example](https://blazor.radzen.com/datagrid-inline-edit):

```auto
    void CancelEdit(Order order)
    {
        ordersGrid.CancelEditRow(order);

        // For production
        var orderEntry = dbContext.Entry(order);
        orderEntry.CurrentValues.SetValues(orderEntry.OriginalValues);
        orderEntry.State = EntityState.Unchanged;
    }

```

Since you are using plain REST service you will need to get original values by yourself - for example you can save the original values in a variable before editing and restore them on cancel.

---

<div class="post-metadata">

**Author:** ![Brian\_McColgan](https://forum.radzen.com/user_avatar/forum.radzen.com/brian_mccolgan/32/3495_2.png) [@Brian\_McColgan](https://forum.radzen.com/u/Brian_McColgan)\
**Post date:** [July 31, 2020, 2:27pm UTC](https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449/3 "2020-07-31T14:27:20Z")

</div>

Thank you Vladimir!

I was saving my original values (prior to my posting) but alas was incorrectly restoring the values. I was incorrectly assigning my edited object to _refer-to_ object holding orig/saved values. I then focused on restoring values vs. assigning object references and all working correctly!

BR/Brian.

---

<div class="post-metadata">

**Author:** ![rsalemi](https://forum.radzen.com/user_avatar/forum.radzen.com/rsalemi/32/16843_2.png) [@rsalemi](https://forum.radzen.com/u/rsalemi)\
**Post date:** [April 9, 2024, 3:11pm UTC](https://forum.radzen.com/t/radzengrid-datagrid-revert-changes-on-cancel-btn/4449/4 "2024-04-09T15:11:50Z")

</div>

Hi, I know this post is a bit old, but how can I manually restore the values of the row for which I undid the change?

I saved the original values in a variable, also in this case I don't have a DBContext but a management of CRUD operations via API.
