我有一个项目列表TechDocBranch,我想在Kendo Blazor树列表中将其表示为树。
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中获取树?
必须为任何列添加可扩展属性才能解决此问题。例如:
<TreeListColumn Field="@nameof(TDB.ID)" Expandable="true"></TreeListColumn>
附言:请注意,Kendo TreeList与Kendo TreeView不同,在大数据量的情况下工作速度较慢。(Blazor的2.18版(