예제 #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);
        }
예제 #2
0
        public static List <JqgridTreeData> GetTreeData <T>(List <T> lstAll, string strID, string strName, string strParent, int Level)
        {
            MemberFactory <T> t = new MemberFactory <T>();

            var lstParent = lstAll.FindAll(a => t.GetValue(a, strParent) == null || t.GetValue(a, strParent).ToString() == "0");


            return(GetTreeDataTemp(lstParent, lstAll, strID, strName, strParent, 0));
        }
예제 #3
0
        public static List <JqgridTreeData> GetTreeDataTemp <T>(List <T> lstParent, List <T> lstAll, string strID, string strName, string strParent, int iLevel)
        {
            var lstRet = new List <JqgridTreeData>();

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

            foreach (var a in lstParent)
            {
                var d = new JqgridTreeData()
                {
                    id       = t.GetValue(a, strID).ToString(),
                    text     = t.GetValue(a, strName).ToString(),
                    level    = iLevel,
                    isLeaf   = false,
                    loaded   = true,
                    expanded = true
                };

                //所有子节点
                var lstTemp = lstAll.FindAll(e => t.GetValue(e, strParent).ToString() == d.id);
                if (lstTemp.Count == 0)
                {
                    d.isLeaf = true;
                }

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

                lstAll.Remove(a);

                //添加子节点及递归子节点的子节点
                GetTreeDataTemp <T>(lstTemp, lstAll, strID, strName, strParent, iLevel + 1);

                lstRet.Add(d);
            }

            // iLevel++;

            return(lstRet);
        }