具有子节点的Devexpress树形结构 [英] Devexpress treelist structure with child nodes
问题描述
<pre lang="c#">
Hello
我有一个产品组的数据库表,其字段名称为父ID。例如,如果您有 Refrigerator 作为产品ID,则它具有 Kitchen Ware ID作为其父ID。我怎样才能在DevExpress中拥有一个treeList,让它的父节点下有子节点?我的数据库是SQL服务器。
我在我的表单中添加了一个有2个colomn的treeList,然后添加一个类来从sql数据库中获取数据:
Hello
I have a Database table for "Products Group" that has a field name "Parent ID". for example if you have "Refrigerator" as you Product ID, it has the "Kitchen Ware" ID as it's Parent ID. How can I have a treeList in DevExpress to have child nodes under it's parent? My database is SQL server.
I have add a treeList in my form that has 2 colomn, then add a class to fetch data from sql database :
public List<LocalProductGroups> GetProductGroups()
{
using (ShoppingEntities _ShoppingEntities = new ShoppingEntities())
{
return _ShoppingEntities.ProductGroup.Select(s => new LocalProductGroups
{
GroupID=s.GroupID,
Name=s.Name,
Parent=s.Parent
}).ToList();
}
}
public partial class LocalProductGroups
{
public int GroupID { get; set; }
public string Name { get; set; }
public int Parent { get; set; }
public bool IsRemove { get; set; }
}
数据显示在treelist中,但不是父母和子女格式,我的意思是所有产品Goups在一个级别。
提前致谢
我尝试过:
我已根据DevExpress文档尝试了上面的代码,但我没有得到答案。
data is shown in treelist but not in parent and child format, I mean all Product Goups are in one level.
Thanks in Advance
What I have tried:
I have tried my code above based on DevExpress documentations, but I have not met my answer.
推荐答案
我发现以下内容:
如何:通过儿童实现分层数据绑定节点选择器 [ ^ ]
树列表中的树生成算法 [ ^ ]
树清单控件的功能 [ ^ ]
显示分层数据 - ASP.NET AJAX树列出演示| DevExpress [ ^ ]
如果它没有用,请回到这里,然后简要介绍一下你试图实现的目标和方法。您使用的一段代码可能会有所帮助。
I've found the following:
How to: Implement Hierarchical Data Binding via Child Nodes Selector[^]
Tree Generation Algorithm in the Tree List[^]
Tree List control's features[^]
Display Hierarchical Data - ASP.NET AJAX Tree List Demo | DevExpress[^]
If it won't help, come back here and shortly describe what have you tried to achieve and how. Piece of code you used may be helpful.
这篇关于具有子节点的Devexpress树形结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!