Refresh Datagrid Not Working

Hello,

So I have a datagrid that has a checkbox associated - when you click the checkbox, it fires off a stored procedure to update values behind the scenes - then it needs to refresh the datagrid to show the new value.

The changing of the values works perfect - I see in the output that it's happening, and if I refresh, I see the updated data - but otherwise the grid0.Reload(); is not refreshing the data - it's still using the same cache. If I have a sort it'll actually

What do I need to do to reload the data from the database?

The grid data most probably are retrieved in Load() method - you can execute it to get latest data: await Load().

Tried that - I can redraw the grid but I can't get it to display the changed data until I refresh the whole page.

Please send us example application at info@rafzen.com where we can reproduce and debug your scenario.

Just sent it your way. The await Load(); probably isn't in there right now but I tried a bunch of different ways with no luck. Thanks for taking a look.

Without await Load(); it will not work

It was there in a previous version - just put it back and tested... not working. Did it work when you tried it? Or am I putting it in the wrong place?

Yes, I was able to reproduce the problem. Instead await Load() you can use await Context.Entry(data).ReloadAsync();


where Context is injected in the page partial class:

Honestly I'm not sure why EF Core will not re-query data after this SP execution - Load() method of the page properly calls the service where the latest data will be retrieved from the context.

1 Like

Awesome - thank you. I do wonder if there's a better way to execute this than calling a SP - it looks like there's a Grid0RowUpdate method I could try that might do this cleaner? I'm just still figuring out the syntax of the args.

RowUpdate is tied to in-line editing feature which is not what you are using.

I have the same problem. When I change datasource and force redraw form via StateHasChanged. I see always old data. It seems that ItemsProviderDelegate in method DrawRows does not call LoadItems in consequent calls. It is correct only during first call.