Grid refresh issue (page load)

Hello,

Having an issue with a datagrid:

The button above is setup in a template the logic is such that AuditID if 0 will display red and point to the "Add New" if it's !=0 then it points to the edit page.

The issue I am having is that when you hit the red button it opens the add page which gets filled out and is submitted, the AuditID is updated to non 0.

This page with the grid loads but the button does not change unless I hit F5 to refresh the page. The data for the grid is loaded during page load event.

What am I missing?

How is this done in Radzen? Can you show us?

Is this page generated by Radzen? Such pages contain some code which refreshes the grid such as await grid0.Reload();

All pages generated by Radzen then edited by me.

6: Audit for the grid is where the buttons live:

Green is shown when AuditID !=0:

Click event goes to Edit page:

This works as it should.

Issue is with the Red button:

Only shown when AuditID == 0 (this is default (can't change) when schedule added)

Click is setup like:

Submit on the add form is:

Stored procedure updates the AuditID on the BBSschedule then navigates to the Edit/View page

The Edit/View page has a close button that navigates to the schedule page. The Schedule page where the grid lives populates however the button does not change to green unless I hit f5 (like it's cached)

I think this is why the data isn't updated in the DataGrid - the page property its Data is set to is never updated by the stored procedure and AuditID stays with the old value. You can try fetching the data again and assigning that property in the Then event of the Click handler (instead of await grid0.Reload()). Alternatively set the AuditID property of the record in the Edit/Add page.

Sorry to be clear the audit add page in dialog when the form is submitted updates the AuditID in the database then navigates to the edit page:

Closing edit page navigates back to the schedule page, should the page load events on the schedule page not fire?

2021-08-03_12-50-22.zip (996.1 KB)

Here is a video of what it's doing.

The Load event should fire if you use Navigate to page. Does it fire when you debug your application? If yes you may be hitting entity framework's caching feature and it could be returning stale values (this can also be verified with the debugger by inspecting what the returned data is).

If the data turns out to be old there are two possible solutions:

  1. Update the AuditID property of the item (not just in the database)
  2. Use AsNoTracking() when getting the items from the database. Radzen can do that automatically but it would require regenerating the CRUD pages of your applications (there is an option in the infer data source screen which is checked by default)
    To avoid regenerating the whole application you can use a partial class for the service that Radzen has generated and define an OnXXXRead partial method (here is an example for an Order entity)
partial void OnOrdersRead(ref IQueryable<Models.Sample.Order> items)
{
   items = items.AsNoTracking();
}

Made a backup of the application first then went to infer, removed the checkmark next to "Enable Entity Framework query tracking" then ran it, it's now working without having to regenerate the crud pages.

Thank you for the guidance you have given and a great product!