TreeView - Async loaded DataSource results in all nodes being selected when using Checkboxes

I am using a SfTreeView component, and the datasource is loaded OnInitializedAsync.
When the component displays, all the top-level nodes are selected (i.e. they all show with a blue background over the row) if I have checkboxes turned on.
e.g.
<SfTreeView @ref="tree" TValue="ClassificationDTO" AllowEditing="true" AllowDragAndDrop="true" ExpandOn="ExpandOnSettings.Click" AutoCheck="true" SortOrder="Syncfusion.Blazor.Navigations.SortOrder.None" FullRowSelect="true" ShowCheckBox="true" AllowMultiSelection="false">
    <TreeViewFieldsSettings TValue="ClassificationDTO" @bind-DataSource="@classifications" Id="Id" Text="Name" ParentID="ParentId" HasChildren="HasChildren" IsChecked="Active" Selected="false" Expanded="true" />
    <TreeViewEvents TValue="ClassificationDTO" NodeSelected="OnSelect" NodeClicked="NodeClicked" />
    <SfContextMenu TValue="ContextMenuItem" @ref="menu" Target="#treeview">
        <ContextMenuEvents TValue="ContextMenuItem" ItemSelected="MenuSelect" />
        <ContextMenuItems>
            <ContextMenuItem Text="Add" />
            <ContextMenuItem Text="Edit" />
            <ContextMenuItem Text="Delete" />
        </ContextMenuItems>
    </SfContextMenu>
</SfTreeView>
@code {

List<ClassificationDTO> classifications;

protected override async Task OnInitializedAsync()
{
    classifications = await caseRepository.GetClassifications();
}

If I turn checkboxes off, the issue does not occur (however, I need them turned on). If I populate the DataSource synchronously, the issue does not occur (but I need to load the data from my WebAPI async).

Does anyone else have this issue, and a workaround?
(Just to clarify, the 'selection' I'm talking about is the selection of the entire row, like the node has been clicked on, not the selection via the checkbox)

3 Replies 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team July 31, 2020 01:47 PM UTC

Hi Stephen McMahon,  
 
Greetings from Syncfusion support. 
 
We have checked your reported issue with TreeView component and able to reproduce it. We consider this as a bug from our end. It will be included in our Volume 3 release which is expected to be released at the end of September 2020.  
 
Track the below link to know the bug status. 
 
 
However, we suggest a workaround to resolve your issue, remove the isChecked property in your application and check the node using checkedNodes property using DataBound event. 
 
<SfTreeView @ref="tree" TValue="ClassificationDTO" AllowEditing="true" AllowDragAndDrop="true" ExpandOn="ExpandOnSettings.Click"  AutoCheck="true" SortOrder="Syncfusion.Blazor.Navigations.SortOrder.None" FullRowSelect="true" ShowCheckBox="true" AllowMultiSelection="false"> 
    <TreeViewFieldsSettings TValue="ClassificationDTO" DataSource="@classifications" Id="Id" Text="Name" ParentID="ParentId" HasChildren="HasChildren" Expanded="Expanded" /> 
    <TreeViewEvents TValue="ClassificationDTO" DataBound="dataBound"></TreeViewEvents> 
</SfTreeView> 
    public async Task dataBound(Syncfusion.Blazor.Navigations.DataBoundEventArgs<ClassificationDTO> args) 
    { 
        tree.CheckedNodes = new string[] { "1" }; 
        tree.DataBind(); 
    } 
 
Refer the sample link below. 
 
 
To know more about the TreeView component, refer the below links. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P


AG Andreas Gabriel October 1, 2020 06:24 AM UTC

If I change your demo little bit and add one line:  await Task.Yield() - or any other real task with await, the treeview doesn't show anymore.

 protected override async Task OnInitializedAsync()
    {
        await Task.Delay(10);   //  --> no data visible!!!
        classifications = await TreeViewService.GetClassifications();

    }


SP Sowmiya Padmanaban Syncfusion Team October 2, 2020 04:38 AM UTC

Hi Andreas Gabriel,  
 
We have checked your reported issue with TreeView component. We have already logged this as a feature improvement task with TreeView component. This feature will be included in Volume 3 SP release which is expected to be released at the end of October 2020. 
 
You can track the following feedback link to know the status of this feature implementation. 
 
 
We appreciate your patience. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon