`
peizhiinfo
  • 浏览: 1439162 次
文章分类
社区版块
存档分类
最新评论

利用递归绑定DevExpress.XtratreeList.TreeList数据

 
阅读更多
在进行项目开发过程中、曾遇到过需用到dev系列的treelist进行数据绑定、将方法贴出来希望对有需要的朋友有所帮助.
1 2 3 /// <summary> 4 /// treeList绑定 5 /// </summary> 6 /// <param name="parent">父ID</param> 7 private void TreeListBind(string parent) 8 { 9 treeList1.Nodes.Clear(); 10 if (collection.Count < 1) 11 return; 12 var items = from s in collection 13 where s.Parent == parent 14 select s; 15 if (items.Count() < 1) 16 return; 17 TreeListNode Node = treeList1.AppendNode("id", null); 18 Node.SetValue(0, "Name"); 23 foreach (var st in items) 24 { 25 if (st.IsDeleted) 26 continue; 27 TreeListNode tn = treeList1.AppendNode(st.ID, Node); 28 tn.SetValue(treeListColumn1, st.Name); 29 tn.Tag = st; 30 GetCentralChild(tn, st.ID.ToString()); 31 } 32 treeList1.ExpandAll(); 33 } 34 35 private void GetCentralChild(TreeListNode tn, string parent) 36 { 37 var items = from s in collection 38 where s.Parent != null && s.Parent == parent 39 select s; 40 if (items.Count() < 1) 41 return; 42 foreach (var st in items) 43 { 44 if (st.IsDeleted) 45 continue; 46 TreeListNode tns = tn.TreeList.AppendNode(st.ID, tn); 47 tns.SetValue(treeListColumn1, st.Name); 48 tns.Tag = st; 49 GetCentralChild(tns, st.ID.ToString()); 50 } 51 }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics