We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

TreeGrid data not loading after a browser back button click

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?

1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 17, 2020 04:09 PM UTC

Hi Scott, 

Thanks for contacting Syncfusion Support. 

Query#:- 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.  

We have prepared sample using your code example but we are unable to reproduce your problem (Grid doesn’t display the rows on browser’s back button at multiple times) at our end.  Refer to the sample Link:- 

Refer to the Video Demo:- 

We need some more additional details to find the cause of the issue. Share us the following details. 
    
  1. Share us the complete TreeGrid code example.
  2. If possible replicate the issue in the above sample and revert us back.
  3. Have you faced the issue on any specific scenario.
  4. Share us the Video demo to replicate the issue.
  5. Can you please bind an actionFailure event to your TreeGrid and share us the args.error stacktrace

Regards, 
Farveen sulthana T 


Loader.
Live Chat Icon For mobile
Up arrow icon