<EjsTreeView TValue="MailItem">
<TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings>
</EjsTreeView>
public class MailItem
{
public Guid Id { get; set; }
public Guid? ParentId { get; set; }
public string FolderName { get; set; }
public bool Expanded { get; set; }
public bool HasSubFolders { get; set; }
}
List<MailItem> MyFolder = new List<MailItem>();
protected override void OnInitialized()
{
base.OnInitialized();
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247482"),
FolderName = "Inbox",
HasSubFolders = true,
Expanded = true
});
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247483"),
ParentId = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247482"),
FolderName = "Categories",
Expanded = true,
HasSubFolders = true
});
} |
protected override void OnInitialized()
{
base.OnInitialized();
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247482"),
ParentId = new Guid(),
FolderName = "Inbox",
HasSubFolders = true,
Expanded = true
});
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247483"),
ParentId = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247482"),
FolderName = "Categories",
Expanded = true,
HasSubFolders = true
});
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247484"),
ParentId = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247483"),
FolderName = "Primary"
});
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247485"),
ParentId = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247483"),
FolderName = "Social"
});
MyFolder.Add(new MailItem
{
Id = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247486"),
ParentId = new Guid("9245fe4a-d402-451c-b9ed-9c1a04247483"),
FolderName = "Promotions"
});
for(var i=0; i<MyFolder.Count; i++)
{
if(MyFolder[i].ParentId == new Guid())
{
MyFolder[i].ParentId = null;
}
}
} |