Example #1
0
        public static List <EasyUITreeData> GetTreeDataTemp <T>(List <T> lstParent, List <T> lstAll, string strID, string strName, string strParent)
        {
            var lstRet = new List <EasyUITreeData>();

            MemberFactory <T> t = new MemberFactory <T>();

            foreach (var a in lstParent)
            {
                var d = new EasyUITreeData()
                {
                    id   = t.GetValue(a, strID).ToString(),
                    text = t.GetValue(a, strName).ToString(),
                };

                //所有子节点
                var lstTemp = lstAll.FindAll(e => t.GetValue(e, strParent).ToString() == d.id);

                //移除已经处理的节点
                lstTemp.ForEach(e => lstAll.Remove(e));

                lstAll.Remove(a);

                //添加子节点及递归子节点的子节点
                d.children = GetTreeDataTemp <T>(lstTemp, lstAll, strID, strName, strParent);

                lstRet.Add(d);
            }

            return(lstRet);
        }
Example #2
0
        public static List <EasyUITreeData> GetTreeData <T>(
            Func <T, List <T>, List <T>, EasyUITreeData> act, List <T> lstSource)
        {
            List <EasyUITreeData> lst = new List <EasyUITreeData>();
            List <T> lstAdded         = new List <T>();


            foreach (T a in lstSource)
            {
                EasyUITreeData obj = new EasyUITreeData();

                var d = act(a, lstAdded, lstSource);
                if (d != null)
                {
                    lst.Add(d);
                }
            }
            return(lst);
        }