[RadzenDataGrid] InsertRow() does not work in certain situations #709

Closed
opened 2026-01-29 17:41:57 +00:00 by claunia · 12 comments
Owner

Originally created by @robertmclaws on GitHub (Jan 29, 2023).

Describe the Bug

We have been migrating our grids to RadzenDataGrid from RadzenGrid. After getting everything else working, it appears that RadzenDataGrid.InsertRow() is not functioning. We have implemented everything from this example and cannot find any differences.

Steps to Reproduce

  1. Clone this repo locally: https://github.com/CloudNimble/RadzenDataGridProblem
  2. Set a breakpoint here.
  3. Hit F5 and let the app run & load.
  4. Click the "Add New Record" button.
  5. Step through it adding a new item.
  6. See that it does not put the row into edit mode.

Expected Behavior

I expect it to behave like the previous RadzenGrid and put a new row in the table and put that row into Edit Mode, just as in this example:
image

Screenshots

image
This is what the screen looks like after you click the button in our reproduction project. Confirmed that the breakpoint has been hit at the method has been called. No rows are added, and no additional errors are listed in the Console.

Environment

  • OS: Windows 11
  • Browser: Edge
  • Version: 109.0.1518.70

Additional context

This is currently blocking us from moving to Production.

Originally created by @robertmclaws on GitHub (Jan 29, 2023). ## Describe the Bug We have been migrating our grids to `RadzenDataGrid` from `RadzenGrid`. After getting everything else working, it appears that `RadzenDataGrid.InsertRow()` is not functioning. We have implemented [everything from this example](https://blazor.radzen.com/datagrid-inline-edit) and cannot find any differences. ## Steps to Reproduce 1. Clone this repo locally: https://github.com/CloudNimble/RadzenDataGridProblem 2. Set a breakpoint [here](https://github.com/CloudNimble/RadzenDataGridProblem/blob/main/Client/Shared/Grids/CloudNimbleGrid.razor#L97). 3. Hit F5 and let the app run & load. 4. Click the "Add New Record" button. 5. Step through it adding a new item. 6. See that it does not put the row into edit mode. ## Expected Behavior I expect it to behave like the previous RadzenGrid and put a new row in the table and put that row into Edit Mode, just as in this example: ![image](https://user-images.githubusercontent.com/1657085/215298913-87941dae-199f-4b1f-80f4-5bf04622a5e7.png) ## Screenshots ![image](https://user-images.githubusercontent.com/1657085/215298840-08bf5f92-d43c-401a-9263-b7b31585de15.png) This is what the screen looks like after you click the button in our reproduction project. Confirmed that the breakpoint has been hit at the method has been called. No rows are added, and no additional errors are listed in the Console. ## Environment - OS: Windows 11 - Browser: Edge - Version: 109.0.1518.70 ## Additional context This is currently blocking us from moving to Production.
Author
Owner

@enchev commented on GitHub (Jan 30, 2023):

I've replaced RadzenDataGrid and RadzenDataGridColumn with RadzenGrid and RadzenGridColumn however the insert didn't worked again.
image
image
image

@enchev commented on GitHub (Jan 30, 2023): I've replaced RadzenDataGrid and RadzenDataGridColumn with RadzenGrid and RadzenGridColumn however the insert didn't worked again. ![image](https://user-images.githubusercontent.com/5804953/215423769-39353443-2c65-418f-9644-5872deb6ba66.png) ![image](https://user-images.githubusercontent.com/5804953/215423802-d1b36ddf-d1ba-4835-ab5e-a5bed6b8f3b7.png) ![image](https://user-images.githubusercontent.com/5804953/215423878-175cff4c-2d79-4c82-b914-a0dc83e95bea.png)
Author
Owner

@robertmclaws commented on GitHub (Jan 30, 2023):

Thanks for looking into it! Odd. I wonder if it's a .NET 7 thing? I'll roll it back to .NET 6 and see if it works.

The last version of Radzen.Blazor that I can guarantee it worked in for RadzenGrid was 3.6.8.

If you want to set those changes as a Pull Request on my repro project, I'll pull it down and see if I can roll back to the last verison / runtime it worked in.

@robertmclaws commented on GitHub (Jan 30, 2023): Thanks for looking into it! Odd. I wonder if it's a .NET 7 thing? I'll roll it back to .NET 6 and see if it works. The last version of Radzen.Blazor that I can *guarantee* it worked in for RadzenGrid was 3.6.8. If you want to set those changes as a Pull Request on my repro project, I'll pull it down and see if I can roll back to the last verison / runtime it worked in.
Author
Owner

@enchev commented on GitHub (Jan 31, 2023):

didn't worked with 3.6.8 as well - pull request submitted.

@enchev commented on GitHub (Jan 31, 2023): didn't worked with 3.6.8 as well - pull request submitted.
Author
Owner

@robertmclaws commented on GitHub (Feb 1, 2023):

I believe I have identified the problem. The code previously worked on .NET 5.0 with version 3.8.6. I was able to reproduce it locally in an older version of BurnRate.

In previous iterations, calling await gridInstance.InsertRow(item); was sufficient to get the Grid into Edit mode. The record was only committed to the underlying List if it was actually edited.

Instead, I'm now having to call:

ViewModel.Entities.Insert(0, item);
await EditRow(entity);

...and simply remove the blank item from the collection if it is deleted before it is persisted.

I will push an update that shows the codebase working, as well as a repo of it working the way it is supposed to on .NET 5.0. I will update this thread when those two branches have been pushed.

@robertmclaws commented on GitHub (Feb 1, 2023): I believe I have identified the problem. The code previously worked on .NET 5.0 with version 3.8.6. I was able to reproduce it locally in an older version of BurnRate. In previous iterations, calling `await gridInstance.InsertRow(item);` was sufficient to get the Grid into Edit mode. The record was only committed to the underlying List if it was actually edited. Instead, I'm now having to call: ```csharp ViewModel.Entities.Insert(0, item); await EditRow(entity); ``` ...and simply remove the blank item from the collection if it is deleted before it is persisted. I will push an update that shows the codebase working, as well as a repo of it working the way it is supposed to on .NET 5.0. I will update this thread when those two branches have been pushed.
Author
Owner

@robertmclaws commented on GitHub (Feb 1, 2023):

Here's the working version on .NET 7 that bypasses gridinstance.InsertRow(): 187555826e

Here's a repro of a working version on .NET 5 + Radzen 3.6.8: bfd06d45a2

I'd really like it to work the way it did in .NET 5. Hope this helps track the problem down. Thanks so much!

@robertmclaws commented on GitHub (Feb 1, 2023): Here's the working version on .NET 7 that bypasses gridinstance.InsertRow(): https://github.com/CloudNimble/RadzenDataGridProblem/commit/187555826e84044f22a6bad8703c321ff409b161 Here's a repro of a working version on .NET 5 + Radzen 3.6.8: https://github.com/CloudNimble/RadzenDataGridProblem/commit/bfd06d45a291dfb416a514fa6445c007f86fb057 I'd really like it to work the way it did in .NET 5. Hope this helps track the problem down. Thanks so much!
Author
Owner

@enchev commented on GitHub (Feb 1, 2023):

Try latest Radzen.Blazor with .NET 5 - if it works then the problem is caused by a change in the EF DbSet. We've not changed anything related to insert.

@enchev commented on GitHub (Feb 1, 2023): Try latest Radzen.Blazor with .NET 5 - if it works then the problem is caused by a change in the EF DbSet. We've not changed anything related to insert.
Author
Owner

@robertmclaws commented on GitHub (Feb 2, 2023):

OK, I spent quite a bit of time rolling through different versions.

.NET 5 + latest: Working
.NET 6 + latest: Working
.NET 7 + latest: Working
.NET 7 + latest [Initial Checkin]: Still not working

Diff between initial version and working version: https://github.com/CloudNimble/RadzenDataGridProblem/compare/initial-version...dotnet7?expand=1
(Focus on the CloudNimbleGrid.razor change)

It looks like setting some of the properties in the original might be causing the problem:
image

If you could look into what could be causing the problem from that, I will continue to try to narrow it down on this end tomorrow. Thanks!

@robertmclaws commented on GitHub (Feb 2, 2023): OK, I spent quite a bit of time rolling through different versions. **.NET 5 + latest:** [Working](https://github.com/CloudNimble/RadzenDataGridProblem/tree/dotnet5) **.NET 6 + latest:** [Working](https://github.com/CloudNimble/RadzenDataGridProblem/tree/dotnet6) **.NET 7 + latest:** [Working](https://github.com/CloudNimble/RadzenDataGridProblem/tree/dotnet7) **.NET 7 + latest [Initial Checkin]:** [Still not working](https://github.com/CloudNimble/RadzenDataGridProblem/tree/initial-version) Diff between initial version and working version: https://github.com/CloudNimble/RadzenDataGridProblem/compare/initial-version...dotnet7?expand=1 (Focus on the CloudNimbleGrid.razor change) It looks like setting some of the properties in the original might be causing the problem: <img width="942" alt="image" src="https://user-images.githubusercontent.com/1657085/216284236-484e0aaa-7d10-4a00-b223-89a66b638dd7.png"> If you could look into what could be causing the problem from that, I will continue to try to narrow it down on this end tomorrow. Thanks!
Author
Owner

@robertmclaws commented on GitHub (Feb 3, 2023):

So I figured out what the problem is. Because the datasource we're using is remote, when the data is loaded well after the Grid is rendered, it's not refreshing the Grid with the new data. We had to set our custom grid wrapper to watch the ViewModel for when the LoadingStatus changed, and call gridInstance.Reload().

@enchev I would suggest that you folks add a RadzenDataGrid.Refresh() method that makes it clear you are just going to update the rendering from the existing data, not reload the underlying data source.

I'll go ahead and close this now. If any future readers want to see the fix, let me know.

@robertmclaws commented on GitHub (Feb 3, 2023): So I figured out what the problem is. Because the datasource we're using is remote, when the data is loaded well after the Grid is rendered, it's not refreshing the Grid with the new data. We had to set our custom grid wrapper to watch the ViewModel for when the LoadingStatus changed, and call gridInstance.Reload(). @enchev I would suggest that you folks add a RadzenDataGrid.Refresh() method that makes it clear you are just going to update the rendering from the existing data, not reload the underlying data source. I'll go ahead and close this now. If any future readers want to see the fix, let me know.
Author
Owner

@DoubleBullet commented on GitHub (Feb 15, 2024):

I have the very same problem and it's very frustrating. I thought the problem was with me and my code, but thankfully, I did a series of tests to figure out that the problem was the insert method.

Strangely, the insert works the first time but doesn't work the second time I call the insert method.

My project is using .NET 8, so I assume it shares the same underlying issue as with .NET 7.

I need to get this fixed for a project I am working on for a client.
Any attempts at fixing this issue would be very much appreciated :)

@DoubleBullet commented on GitHub (Feb 15, 2024): I have the very same problem and it's very frustrating. I thought the problem was with me and my code, but thankfully, I did a series of tests to figure out that the problem was the insert method. Strangely, the insert works the first time but doesn't work the second time I call the insert method. My project is using .NET 8, so I assume it shares the same underlying issue as with .NET 7. I need to get this fixed for a project I am working on for a client. Any attempts at fixing this issue would be very much appreciated :)
Author
Owner

@DoubleBullet commented on GitHub (Feb 18, 2024):

So I figured out what the problem is. Because the datasource we're using is remote, when the data is loaded well after the Grid is rendered, it's not refreshing the Grid with the new data. We had to set our custom grid wrapper to watch the ViewModel for when the LoadingStatus changed, and call gridInstance.Reload().

@enchev I would suggest that you folks add a RadzenDataGrid.Refresh() method that makes it clear you are just going to update the rendering from the existing data, not reload the underlying data source.

I'll go ahead and close this now. If any future readers want to see the fix, let me know.

I can confirm that this problem only happens when the data source is remote and has changed.
What is the best way to work around this problem?

@DoubleBullet commented on GitHub (Feb 18, 2024): > So I figured out what the problem is. Because the datasource we're using is remote, when the data is loaded well after the Grid is rendered, it's not refreshing the Grid with the new data. We had to set our custom grid wrapper to watch the ViewModel for when the LoadingStatus changed, and call gridInstance.Reload(). > > @enchev I would suggest that you folks add a RadzenDataGrid.Refresh() method that makes it clear you are just going to update the rendering from the existing data, not reload the underlying data source. > > I'll go ahead and close this now. If any future readers want to see the fix, let me know. I can confirm that this problem only happens when the data source is remote and has changed. What is the best way to work around this problem?
Author
Owner

@DoubleBullet commented on GitHub (Feb 28, 2024):

Hello @robertmclaws , I'm interested in having this fixed. Did you manage to find a workaround for .NET 7/8?

@DoubleBullet commented on GitHub (Feb 28, 2024): Hello @robertmclaws , I'm interested in having this fixed. Did you manage to find a workaround for .NET 7/8?
Author
Owner

@DoubleBullet commented on GitHub (Apr 17, 2024):

Will this ever be fixed?

@DoubleBullet commented on GitHub (Apr 17, 2024): Will this ever be fixed?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#709