Refresh Issue


I have a little problem with refreshing a datagrid. Maybe you can help:

I have a page with a datagrid showing entities from a table. In the Load() method, the data is loaded.

Now, I have a button on the page that executes a method:

await RemoteUpdate()

combined with a condition to show a confirmation dialog upfront:

await DialogService.Confirm("Do you want to proceed?") == true

The RemoteUpdate() method does this:

using (HttpClient client = new HttpClient())
    var response = await client.PutAsync("http://someurltomywebservice/", null);

    if (!response.IsSuccessStatusCode)
        NotificationService.Notify(NotificationSeverity.Error, "Error", response.Content.ReadAsStringAsync().Result, 5000);
        NotificationService.Notify(NotificationSeverity.Info, "Success", "Result: " + response.Content.ReadAsStringAsync().Result, 5000);

        await Load();
        await grid0.Reload();
        await InvokeAsync(StateHasChanged);

The code works fine, which means the confirm dialog is shown and if I click on OK, the web service is called and the result is displayed as a notification on the screen. The call also (remotely) updates the database with the entities shown on the gird.

Now, I need to update the grid. Using the code above, it does not work, but if I click the "Reload" button of the browser, the grid shows the correctly updated data.

How can I programatically update the grid and why does the code above not work? Load() should query the database and grid0.Reload() should update the grid...

Any help is welcome!

The problem might be caused by enabled query tracking:

Not quite sure if this is really the cause. I assume that calling the Load() method of a page should get the current data from the database. What I am doing here is calling Load() for the first time when the page is loaded. I get the current state of the database. Then I modify the databse externally (this does not happen in Radzen, only on SQL level and externally). As a result the current state of the database does not reflect what is shown on the grid. So I need to requery the data from the database. That is why I call Load() again. This should behave exactly like when the page is first loaded and should get the current state from the database. Am I missing something?

Have you tried to disable query tracking as I suggested?

You are right - this is EF related. I cannot disable query tracking since I need to keap track of changes for different functions on that page.

What I did is that I simply call:

uriHelper.NavigateTo(uriHelper.Uri, forceLoad: true);

to really "reload" the page in the browser. This updates my data. However, from other postings in this forum I have seen that this is a common issue. Would be great to have a solution here on day that allows to "force" the reload without loosing change tracking as a result.