DataGrid Inline Add issues when there's error

Hello Radzen team,

I am having some issues with saving a new row in inline edit grid. When a new row is added in an inline edit grid and if there's an error when saving this happens.

Clicked Add button-> Added values to the new row inserted

I had a error notification as there's a unique key error from database. After that the row becomes like this with no cancel button and only edit button showing with id as 0 even though it hasn't been saved to database.

If I click edit button and try to save changes again , it doesn't save. I tried with same data and also modified data that doesn't have errors.

I have to reload the grid to remove it. It looks like once the save button is clicked, the row is marked as edit only which will fail as id is 0.
I tried adding a grid reload and insert row with the unsaved data if error occurs in the create event handler but when I click save button it still goes into update row event handler instead of create row handler and there doesn't seem to be a flag to reset.

Code behind

The same thing can be seen in Radzen demo also -

I want to retain the data in the new row so the user doesn't have to input everything from scratch. But also keep it as a new row until save succeeds or I reload the grid.

Can you please give me some pointers on how to get it done?

You can try the following:

  1. Handle the Error event of your CreateXXX method (invoked in the RowCreate event of the DataGrid). There call CancelEditRow:


    and set a flag that the insert has failed:

  2. Edit the Click handler of the Save button (it is in the EditTemplate of the second to last column). Change the UpdateRow to await grid0.UpdateRow(${data}).


    Then add a new Execute C# action which will call await grid0.InsertRow(${data}) if insertFailed is true.
    Finally set the flag to false.

@korchev Thank you, Will try that.

Is this error handling something that can be implemented in Radzen (feature request) so it will automatically be handled instead of the customization for every grid?

Yes, we will consider it for a future Radzen release.

Awesome. Thank you so much.