I have a Blazor server razor view using Radzen tabs which has 3 tabs. Each tab is having child razor component (Job,Queue,DB) like below. I see 2 issues, which needs help.
-
At Index.razor.cs, only first child is getting initialized on load and even on any tab click. So rest 2 child are null value. Not getting initialized and so not able to access child methods like Load, refresh.
-
Main issue, when i switch from 1st tab to 2nd tab and switch back to 1st tab, child data is not getting displayed on first click eventhough service call returns data & statehaschanged is being called. On second click of same 1st tab, data is being shown by making another service call. so i have to click tab twice to show the data in child. each child calls statehaschanged after service calls.
Index.razor
<RadzenTabs Change=@OnTabChange style="height: 530px;width:100%">
<Tabs>
<RadzenTabsItem Text="Jobs">
<Job @ref="JobView"> </Job>
</RadzenTabsItem>
<RadzenTabsItem Text="Queues" >
<Queue @ref="QueueView"></Queue>
</RadzenTabsItem>
<RadzenTabsItem Text="DB Locks BLocking Locks" >
<DB @ref="@DBView"></DB>
</RadzenTabsItem>
</Tabs>
</RadzenTabs>
Index.razor.cs - here calling the child comp load based on tab index
switch (_tabIndex)
{
case 0:
await JobView.LoadJobs(_name);
case 1:
.....
}
Job.razor.cs - here loading the child comp based on tab index
public async Task LoadJob(string name)
{
JobListList = await _service.GetJobs(name);
await InvokeAsync(() =>
{
StateHasChanged();
});
}