Hi.
I have been working on solving this issue with Blazor Grid, REST, and CustomAdaptor.
Attached is a copy of the application, and a video showing the issue.
The main issue I am seeing is the error I am getting the first time the grid tries to load. As shown in the video, it works fine after the first time, but also seems to take a different path through the code.
First Time Execution:
------------------------------------------------------------
1. run the application
2. click on the sft_rest_2 option in the menu
3. Code steps into the OnInitiallizeAsyc method - as expected
4. It then make a call to the data service to get all the records
5. Data service the does an http get to the REST api/order endpoint
6. At this point, the Custom Adaptor for the razor page, READ method is called
-in subsequent execution, this is not the next step - you will see the debugger to to the REST controller - that does not happen here
In the output windows I see massages like this - it almost looks like the REST call could not be made. Is this because the Grid object interrupted??
info: System.Net.Http.HttpClient.IOrderDataService.ClientHandler[100]
Sending HTTP request GET https://localhost:44319/api/order
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'y8kTfFBxHys8v0T6pkTk4_gzJdF7dt34RKafQvrH_tU'.
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Blazor.Grids.SfGrid`1.GenerateAndExecuteQuery(Query query, Boolean foreignKeyHandle, Boolean isForeignKeyAction, Int32 VirtualStartIndex, Int32 VirtualEndIndex, Boolean isQueryGenerated, Boolean preventForeign)
at Syncfusion.Blazor.Grids.SfGrid`1.DataProcessChildContent(ActionArgs action, ActionEventArgs`1 actionArgs, Boolean foreignKeyHandle, Boolean isForeignKeyAction)
at Syncfusion.Blazor.Grids.SfGrid`1.DataProcessChild(ActionArgs action, ActionEventArgs`1 actionArgs)
at Syncfusion.Blazor.Grids.SfGrid`1.DataProcess(ActionArgs action, ActionEventArgs`1 actionArgs)
at Syncfusion.Blazor.Grids.SfGrid`1.DataProcess(ActionArgs action, ActionEventArgs`1 actionArgs)
at Syncfusion.Blazor.Grids.SfGrid`1.OnAfterScriptRendered()
at Syncfusion.Blazor.SfBaseComponent.InvokeScriptRendered()
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
7. In the custom adaptor read method, the dataset is not populated, the comes back null.
8. It then goes back and runs the OnInitiallizeAsyc again, but even though it gets a dataset this time, you will see that that page has now loaded with an error
Subsequent Executions:
------------------------------------------------------------
The first execution is the only one that fails. After that you will see in the video it progresses in a more expected way. Somehow, on the first execution the HTTP GET seems to get interrupted.
I am hoping you can shed some light on this issue.
|
public override object Read(DataManagerRequest dm, string key = null)
{
IEnumerable<Order> DataSource = Orderz;
if ( Orderz == null){
return null;
}
} |
The main question I have, is should
Orderz be null the first time through? You have suggested 2 possible solutions, in your estimation, which is the best way to approach this? Is this issue related to the async read?