Duplicate node created when dragging and dropping.

Hi,

I am getting some strange behaviour when dragging and dropping nodes where the dragged node moves to where it should go but a duplicate is also created at the root level.  See the attached gif for an example of it happening.

I have a blank project and here is the code from my page:


@page "/tree"
@using Syncfusion.Blazor.Navigations

<link rel='nofollow' href="/css/custom.css" rel="stylesheet" />
<h1>Tree Drag Test</h1>

<SfTreeView TValue="MailItem" AllowDragAndDrop="true">
    <TreeViewFieldsSettings TValue="MailItem" Id="Id" Text="FolderName" Child="SubFolders" DataSource="@MyFolder" Expanded="Expanded"></TreeViewFieldsSettings>
</SfTreeView>

@code {
    public class MailItem
    {
        public string Id { get; set; }
        public string FolderName { get; set; }
        public bool Expanded { get; set; }
        public List<MailItem> SubFolders { get; set; }
    }

    List<MailItem> MyFolder = new List<MailItem>();

    protected override void OnInitialized()
    {
        base.OnInitialized();
        List<MailItem> Folder1 = new List<MailItem>();
        MyFolder.Add(new MailItem
        {
            Id = "01",
            FolderName = "Inbox",
            SubFolders = Folder1
        });

        List<MailItem> Folder2 = new List<MailItem>();

        Folder1.Add(new MailItem
        {
            Id = "01-01",
            FolderName = "Categories",
            SubFolders = Folder2
        });
        Folder2.Add(new MailItem
        {
            Id = "01-02",
            FolderName = "Primary"
        });
        Folder2.Add(new MailItem
        {
            Id = "01-03",
            FolderName = "Social"
        });
        Folder2.Add(new MailItem
        {
            Id = "01-04",
            FolderName = "Promotions"
        });

        List<MailItem> Folder3 = new List<MailItem>();

        MyFolder.Add(new MailItem
        {
            Id = "02",
            FolderName = "Others",
            Expanded = true,
            SubFolders = Folder3
        });
        Folder3.Add(new MailItem
        {
            Id = "02-01",
            FolderName = "Sent Items"
        });
        Folder3.Add(new MailItem
        {
            Id = "02-02",
            FolderName = "Delete Items"
        });
        Folder3.Add(new MailItem
        {
            Id = "02-03",
            FolderName = "Drafts"
        });
        Folder3.Add(new MailItem
        {
            Id = "02-04",
            FolderName = "Archive"
        });
    }
}


Attachment: TreeDragIssueGif_ff008b62.zip

3 Replies

SM Shalini Maragathavel Syncfusion Team November 10, 2021 07:40 AM UTC

Hi Tao, 
 
Greetings from Syncfusion support.  
 
We have validated your reported issue with TreeView component and considered the reported scenario “Drag and drop creates the duplicate nodes in TreeView” as a bug from our end. The fix for this issue will be included in Volume 4 release by the mid of December 2021.    

You can track the status of your reported problem through the below portal link. 
  

Until then, we appreciate your patience. 

Regards,
Shalini M. 



TA Tao November 11, 2021 08:45 AM UTC

Thank you for your reply.  This behaviour only seems to happen when I am using local data that is "Hierachical".  When I am using "self-referential" data it doesn't seem to happen.

The problem is I need to be able to read the nodes back out in the order they have been dragged & dropped as I am using that to save my own data after the user has moved things around.

In hierachical mode I can do this by getting the root nodes and then recurse down the tree and read the child nodes and they appear to me in the order they have been dropped.

In self-referential mode ALL the nodes are in my own C# List but I don't seem to be able to see them in the order they are rendered.

If you have a way for me to get self-referential nodes out in the correct order I can use that as a work around until the fix for this issue arrives in December.

Many thanks.



IL Indhumathy Loganathan Syncfusion Team November 12, 2021 02:18 PM UTC

Hi Tao, 
 
Based on the shared details, we understood that you want to get the updated order of nodes after performing drag and drop on TreeView nodes. You can use our TreeView GetTreeData method to get the complete datasource in the modified order. For your reference, we have prepared a simple sample to get the datasource in a button click after performing drag and drop. 
 
Check the below code snippet. 
 
<button @onclick="click">GetNodeOrder</button> 
<SfTreeView @ref="treeview" TValue="MailItem" AllowDragAndDrop="true"> 
    <TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings> 
</SfTreeView> 
 
@code{ 
    SfTreeView<MailItem> treeview; 
    ... 
    public void click() 
    { 
        var treeData = treeview.GetTreeData(); 
    } 
} 
 
You can find the sample from below link. 
 
 
Kindly check the sample. If we have misunderstood, please elaborate on your exact requirement with TreeView and the code snippets you have tried with Hierarchical dataSource which will help us to assist you promptly. 
 
Please let us know if you need any further assistance. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon