コード例 #1
0
        //public List<ItemsGuidVM> getForTree()
        //{
        //    var q = itemsGroupsRepo.GetAll();
        //    var q_Child = itemsRepo.GetAll();
        //    List<ItemsGuidVM> result = new List<ItemsGuidVM>();
        //    foreach (var item in q)
        //    {
        //        ItemsGuidVM itemObj = new ItemsGuidVM()
        //        {
        //            id = item.GROUP_ID,
        //            text = item.GROUP_CODE + " - " + item.GROUP_AR_NAME,

        //        };

        //        foreach (var itemChild in q_Child)
        //        {
        //            if (item.GROUP_ID == itemChild.GROUP_ID)
        //            {
        //                itemObj.children.Add(new childItem()
        //                {
        //                    id = itemChild.ITEM_ID,
        //                    text = itemChild.ITEM_CODE + " - " + itemChild.ITEM_AR_NAME
        //                });
        //                //result.
        //            }

        //        }
        //        result.Add(itemObj);
        //    }
        //    return result;
        //}

        public List <ItemsGuidVM> getForTree()
        {
            var q       = buildItemsTree();
            var q_Child = itemsRepo.GetAll();
            List <ItemsGuidVM> result = new List <ItemsGuidVM>();

            foreach (var item in q)
            {
                ItemsGuidVM itemObj = item;

                foreach (var itemChild in q_Child)
                {
                    if (item.id == itemChild.GROUP_ID)
                    {
                        itemObj.children.Add(new ItemsGuidVM()
                        {
                            id   = itemChild.ITEM_ID,
                            text = itemChild.ITEM_CODE + " - " + itemChild.ITEM_AR_NAME
                        });
                        //result.
                    }
                }
                result.Add(itemObj);
            }
            return(result);
        }
コード例 #2
0
        public void GetTreeView(List <ItemsGuidVM> list, ItemsGuidVM current, ref List <ItemsGuidVM> result)
        {
            // get child of current items

            var childs = list.Where(a => a.PARENT_ACC_ID == current.id);

            current.children = new List <ItemsGuidVM>();
            current.children.AddRange(childs);
            foreach (var i in childs)
            {
                GetTreeView(list, i, ref result);
            }
        }