Example #1
0
        public async Task <IActionResult> GetTreeGridJson(string keyword)
        {
            IEnumerable <Column2Model2DictionaryEntity> list = await columnService.GetAllColumn2Model2DictionaryListAsync();

            var data = list.ToList();

            if (keyword.IsNotNullOrEmpty())
            {
                data = data.TreeWhere(t => t.C_NAME.Contains(keyword), "C_ID", "C_PARENTID");
            }
            var treeList = new List <TreeGridModel>();

            foreach (Column2Model2DictionaryEntity item in data)
            {
                TreeGridModel treeModel   = new TreeGridModel();
                bool          hasChildren = data.Count(t => t.C_PARENTID == item.C_ID) == 0 ? false : true;
                treeModel.id         = item.C_ID;
                treeModel.isLeaf     = hasChildren;
                treeModel.parentId   = item.C_PARENTID;
                treeModel.expanded   = hasChildren;
                treeModel.entityJson = item.ToJson();
                treeList.Add(treeModel);
            }
            return(Content(treeList.TreeGridJson()));
        }