Completed
Last Updated: 23 Aug 2019 13:17 by ADMIN
Release 1.6.0
Andriy
Created on: 12 Aug 2019 10:03
Category: TreeView
Type: Bug Report
2
Changing the data source with different expand states results in Microsoft.JSInterop.JSException: 'Cannot read property 'scrollHeight' of null
When you change the data source of the treeview and the new data has a different set of Expanded states than the old data, you will get a `Microsoft.JSInterop.JSException: 'Cannot read property 'scrollHeight' of null` in VS. It will also fail to show you proper debug information, symbols and source code.


Simple Repro

@using Telerik.Blazor.Components.TreeView
 
<button class="btn btn-primary" @onclick="@(() => ChangeTreeData(false))">Change tree data</button>
 
<TelerikTreeView Data="@FlatData">
    <TelerikTreeViewBindings>
        <TelerikTreeViewBinding ParentIdField="Parent" ExpandedField="IsExpanded"></TelerikTreeViewBinding>
    </TelerikTreeViewBindings>
</TelerikTreeView>
 
@code {
    public List<TreeItem> FlatData { get; set; } = new List<TreeItem>();
 
    public class TreeItem //most fields use the default names and will bind automatically in this example
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public int? Parent { get; set; } //this is a non-default field name
        public bool HasChildren { get; set; }
        public bool IsExpanded { get; set; } //this is a non-default field name
    }
 
    protected override void OnInit()
    {
        ChangeTreeData(true);
    }
 
    int currIndex { get; set; } = 0;
 
    void ChangeTreeData(bool expandItems)
    {
        currIndex++;
 
        FlatData.Clear();
 
        List<TreeItem> data = new List<TreeItem>();
 
        data.Add(new TreeItem { Id = currIndex, HasChildren = true, IsExpanded = expandItems, Parent = null, Text = $"root {currIndex}" });
        data.Add(new TreeItem { Id = currIndex + 1, HasChildren = false, IsExpanded = expandItems, Parent = currIndex, Text = $"root {currIndex}: child one" });
 
        FlatData.AddRange(data);
    }
 
}
1 comment
ADMIN
Marin Bratanov
Posted on: 19 Aug 2019 15:18
Hi to anyone following this,

We are working on it, and I am leaving here for posterity another test case that leads to the same error: https://feedback.telerik.com/blazor/1425832-treeview-with-a-template-returns-error-microsoft-jsinterop-jsexception-cannot-read-property-scrollheight-of-null-when-randomly-clicking-around-the-tree.


Regards,
Marin Bratanov
Progress Telerik UI for Blazor