Unable to select item in the tree consistently

I have the following setup

            <SfTreeView ID="treeview" @ref="elementTree" TValue="LearningElement" FullRowSelect="true" AllowMultiSelection="true">
                <TreeViewEvents TValue="LearningElement" NodeSelected="TreeItemSelected"></TreeViewEvents>
                <TreeViewFieldsSettings TValue="LearningElement" Id="NodePath"
                                        Text="Name"
                                        DataSource="@Elements"
                                        Child="@ElementChildren"
                                        Selected="Selected"
                                        Expanded="Expanded"></TreeViewFieldsSettings>
                <TreeViewTemplates>
                    <NodeTemplate>
                        @{
                            var element = ((context as LearningElement));
                            <div class="small">@element.Name</div>
                        }
                    </NodeTemplate>
                </TreeViewTemplates>
            </SfTreeView>


        protected void TreeItemSelected(NodeSelectEventArgs args)
        {
            if (args.NodeData.Id != null)
            {
                // Do Something
            }
        }

    internal void SetSelectedItem(string nodePath)
        {
            try
            {
                if (elementTree != null)
                {
                    elementTree.SelectedNodes = new string[] { nodePath  };
                    InvokeAsync(() => StateHasChanged());
                }
            }
            catch (Exception ex)
            {
            }
        }

The problem is as follows:

  1. Initial Load - tree loads up fine.
  2. User clicks a button which calls SetSelectedItem() to select a node in the tree  (Item #1) . The item is highlighted, and TreeItemSelected() fires.
  3. User clicks on a node in the tree. TreeItemSelected() fires.
  4. Now user clicks on the button again. This calls SetSelectedItem()but this time, the item in the tree is NOT highlighted, and TreeItemSelected() does NOT fire.
Attached is the screen shot for the steps. Any thoughts on this? 


Attachment: Selecting_Tree_Nodes_Programmatically_6fb1cfb.zip

4 Replies 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team September 10, 2020 12:40 PM UTC

Hi Joseph Tan 
 
Greetings from Syncfusion support. 
 
We have validated your reported issue and found that it occurs because the selected items  is not maintained properly in the selectedItems  property. We have considered this as a bug in TreeView component. We will include the fix for this issue in our Volume 3 release which is expected to be rolled out in the end of September 2020. 
 
You can track the following feedback portal link to the status of bug fix. 
 
 
We appreciate your patience. 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team October 5, 2020 06:27 AM UTC

 
Hi Joseph Tan  
  
Sorry for the inconvenience.  
          
Due to some technical complexities, we were unable to include this fix in Volume 3 release. Currently, we are working with high priority on this fix.   
  
This fix will be included in our Volume 3 SP1 release which is expected to be rolled out in the end of October 2020.   
     
We appreciate your patience.     
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team November 3, 2020 02:05 PM UTC

Hi Joseph Tan,  
 
Sorry the inconvenience. 
 
Due to some technical difficulties, we were unable to include this fix in Volume 3 SP1 release, 2020. We are working on this issue with high priority. 
  
We will include this fix in Volume 4 release which is expected to be rolled out by the end of December 2020. 
  
We appreciate your patience. 
  
Regards, 
Sowmiya P. 



SP Sowmiya Padmanaban Syncfusion Team February 1, 2021 06:25 AM UTC

Hi Joseph, 
 
Thanks for your patience. 
 
We are glad to announce that our Essential Studio 2020 Volume 4 SP release v18.4.0.39 is rolled out and is available for download under the following link. 
 
 
In this release, we have included the fix for “Unable to select the previously selected nodes dynamically via SelectedNodes property”. Please upgrade your package to latest version (18.4.0.39) to resolve the issue.  
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon