18.3.0.35 Display of data in intermittent when loaded in OnInitializedAsync

In 18.3.0.35 the TressGrid will not show the loaded data. I have confirmed that the data is loaded in the OnInitializedAsync with a console write of the record count it always returns 57 records. On first load no data is shown, i.e. 'No records to display' , I can hit refresh in the browser it usually shows no data, but on rare occasions it will load the data, another refresh and it's gone.

        <SfTreeGrid @ref="@TreeGrid"
                    TValue="AggregateStat"
                    IdMapping="Id"
                    ParentIdMapping="ParentId" 
                    DataSource="TreeData"
                    AllowPaging="true"
                    AllowFiltering="true"
                    AllowReordering="false"
                    AllowResizing="true"
                    AllowSorting="true"
                    EnableCollapseAll="true"
                    AllowMultiSorting="true"
                    TreeColumnIndex="1">

            <TreeGridEvents TValue="AggregateStat"
                            RowDataBound="OnRowDataBound"
                            ContextMenuOpen="OnContextMenuOpen"
                            ContextMenuItemClicked="OnContextMenuClick" />
            <TreeGridFilterSettings Type="Syncfusion.Blazor.TreeGrid.FilterType.Excel" />
            <TreeGridPageSettings PageSizes="true" />
            <TreeGridColumns>
                <TreeGridColumn Field="Id" HeaderText="Id" Visible="false" />
                <TreeGridColumn Field="Key" HeaderText="Company" Width="400" />
                <TreeGridColumn Field="Status" HeaderText="Status" Width="150" />
                <TreeGridColumn Field="Count" HeaderText="# Submitted" Width="150" AllowFiltering="false" />
                <TreeGridColumn Field="Total" HeaderText="Total" Width="150" Format="C2" AllowFiltering="false" />
                <TreeGridColumn Field="Minimum" HeaderText="Minimum" Width="150" Format="C2" AllowFiltering="false"></TreeGridColumn>
                <TreeGridColumn Field="Average" HeaderText="Average" Width="150" Format="C2" AllowFiltering="false"></TreeGridColumn>
                <TreeGridColumn Field="Maximum" HeaderText="Maximum" Width="150" Format="C2" AllowFiltering="false"></TreeGridColumn>
            </TreeGridColumns>
        </SfTreeGrid>

--------------

       public List<AggregateStat> TreeData { get; set; } = new List<AggregateStat>();
        protected SfTreeGrid<AggregateStat> TreeGrid { get; set; }

        protected override async Task OnInitializedAsync()
        {
            var authenticationStateProvider = await AuthenticationStateProvider.GetAuthenticationStateAsync();
            UserId = authenticationStateProvider.User.Identity.Name.Split("@")[0];

            ShowSpinner = true;
            using (var context = ConnectDbFactory.CreateDbContext())
            {
                try
                {
                    var clients = await context.Clients
                        .ToDictionaryAsync(r => r.ClientId);
                    var contacts = await context.ClientContacts
                        .ToDictionaryAsync(r => r.ClientContactId);

                    ClientsWithInvoices = await context.Invoices
                        .Where(r => contacts.Keys.Contains(r.ClientContactId))
                        .Select(r => r.ClientContactId)
                        .ToListAsync();

                    var stats = await context.ClientStats
                        .AsNoTracking()
                        .Select(r => new AggregateStat()
                        {
                            Id = r.ClientId,
                            Key = clients[r.ClientId].Organization,
                            Maximum = r.Maximum ?? 0,
                            Minimum = r.Minimum ?? 0,
                            Average = r.Average ?? 0,
                            Count = r.Invoices ?? 0,
                            LastInvoiced = r.LastInvoicedOn,
                            Total = r.Total ?? 0,
                            Status = string.Empty,
                            ParentId = null
                        }).ToListAsync();

                    var clientContactStats = await context.ClientContactStats
                        .AsNoTracking()
                        .Select(r => new AggregateStat()
                        {
                            Id = r.ClientContactId,
                            Key = $"{contacts[r.ClientContactId].ContactName}",
                            Maximum = r.Maximum ?? 0,
                            Minimum = r.Minimum ?? 0,
                            Average = r.Average ?? 0,
                            Count = r.Invoices ?? 0,
                            Total = r.Total ?? 0,
                            Status = r.Status,
                            LastInvoiced = r.LastInvoicedOn,
                            ParentId = contacts[r.ClientContactId].ClientId
                        }).ToListAsync();

                    TreeData = stats;
                    ShowSpinner = false;
                    Console.WriteLine($"TreeData Count {TreeData.Count}");

                }
                catch (Exception ex)
                {
                    ShowSpinner = false;
                    Logger.LogError("Data Load Error", ex);
                    await MessageDialog.ShowModal("Data Load Error", "Unable to load data.");
                }
            }
        }

It worked in 18.2.0.59

Scott

4 Replies

SL Scott Lambert October 5, 2020 12:21 PM UTC

I added the TreeGrid.Refresh command after I loaded and set the treegrid data in the OnInitialkizeAsync method and I have the @ref=TreeeGrid razor page for the TreeGrid.

But when the code hits the TreeGrid.Refresh statement the TreeGrid is null.

Scott




PK Padmavathy Kamalanathan Syncfusion Team October 5, 2020 01:04 PM UTC

Hi Scott, 
 
Thanks for contacting Syncfusion Forums. 
 
Query 1:  on rare occasions it will load the data, another refresh and it's gone 
 
We have created sample with your code. But we are unable to reproduce the issue with version 18.3.0.35 at our end. Please check the below sample, 
 
Kindly share us the below details so that we could proceed further, 
  1. If possible, kindly share us issue reproducible sample or reproduce the issue in the above sample
  2. Also kindly confirm us your dot net version
  3. Video demonstrating the issue.
  4. Screenshot of error with stack trace if any
 
Query 2 : I added the TreeGrid.Refresh command after I loaded and set the treegrid data in the OnInitialkizeAsync method 
 
There is no need to call “Refresh” method after loading the data to Tree Grid. It would work fine without calling this method. Kindly share us the details requested above which would help us in checking the issue. 
 
Regards, 
Padmavathy Kamalanathan 



SL Scott Lambert October 5, 2020 02:26 PM UTC

I am using flat data as opposed to hierarchical data, but your example did point me to my problem. In the OnConfiguringAsync method I was setting the  TreeData (List) to a new list pulled from the database. I changed this so that it uses TreeData.AddRange.

I reckon that the TreeData binding doesn't see that the list has been set to a new list.

I don't know if this is intended or if it is a bug, but from my experience, this is a different behavior than was present in 18.2.0.59.

Thanks, for your timely response,

Scott 


PK Padmavathy Kamalanathan Syncfusion Team October 6, 2020 02:34 PM UTC

Hi Scott, 
 
In order to discuss the issue, we have created new incident. Please check the below link, 
 
Note: To view the incident , kindly login into your account. 
 
Regards, 
Padmavathy Kamalanathan 


Loader.
Up arrow icon