I have a TreeGrid populated via an SQL datasource. It displays and works great. When the user clicks a row, I use NavigationManager to redirect the user to the detail page. I am using this approach so the users can bookmark the url with to the detail page with /MyPage/{Id} like url.
When I click the browser's back button it reloads the data successfully; however, about 1 in 5 times the grid doesn't display the databound rows in the grid UI. I have checked and the TreeData is populated, it is just not showing.
protected async void RowSelectHandler(Syncfusion.EJ2.Blazor.Grids.RowSelectEventArgs<Node> Args)
{
// Open Page control
this.SelectedRecords = await this.TreeGrid.GetSelectedRecords(); /// get the selected records
if (this.SelectedRecords != null && this.SelectedRecords.Count != 0)
{
NavigationManager.NavigateTo("/MyPage/" + this.SelectedRecords[0].Id, false);
}
}
protected override Task OnParametersSetAsync()
{
GetData();
return base.OnParametersSetAsync();
}
private async void GetData()
{
var dbRecords = await dal.SearchAsync(); /// Call to EF core to get data from database
foreach (var r in dbRecords)
{
Node node = new Node
{
Id = r.Id,
ParentId = r.ParentId,
Code = r.Code,
Name = r.Name
};
TreeData.Add(node);
}
StateHasChanged(); /// tried this, but still an issue
base.StateHasChanged(); /// tried this, but still an issue
this.TreeGrid.Refresh(); /// tried this, but still an issue
}
Any ideas?