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"
});
}
}
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.
<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();
}
} |