我有一个 TechDocBranch 项目列表,我想在Kendo Blazor TreeList中将其表示为一棵树。
public class TechDocBranch
{
public long ID { get; set; }
public long ParentID { get; set; }
public string Title { get; set; }
// some another fields
}
我写了以下代码:
<TelerikTreeList Data="@TechDocBranches"
IdField="@nameof(TechDocBranch.ID)"
ParentIdField="@nameof(TechDocBranch.ParentID)">
<TreeListColumns>
<TreeListColumn Field="@nameof(TechDocBranch.ID)"></TreeListColumn>
<TreeListColumn Field="@nameof(TechDocBranch.Title)"></TreeListColumn>
<TreeListColumn Field="@nameof(TechDocBranch.ParentID)"></TreeListColumn>
</TreeListColumns>
</TelerikTreeList>
@code {
public List<TechDocBranch> TechDocBranches;
protected override async Task OnInitializedAsync()
{
TechDocBranches = await ProductionService.GetTechDocBranches();
}
}
但它给了我一张简单的桌子,而不是一棵树。我尝试使用 TreeView(仅更改了 html):
<TelerikTreeView Data="@TechDocBranches">
<TreeViewBindings>
<TreeViewBinding
IdField="@nameof(TechDocBranch.ID)"
TextField="@nameof(TechDocBranch.Title)"
ParentIdField="@nameof(TechDocBranch.ParentID)">
</TreeViewBinding>
</TreeViewBindings>
</TelerikTreeView>
它工作正常并给了我树。
我应该怎么做才能在 TreeList 中获取树?