コード例 #1
0
        public ActionResult GetTreeJson(string queryJson)
        {
            DataItemCache dataItemCache  = new DataItemCache();
            var           formModuleData = formmodulebll.GetList();
            var           data           = dataItemCache.GetDataItemList("FormSort");
            var           treeList       = new List <TreeEntity>();

            foreach (DataItemModel item in data)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = true;//此处做下判断
                tree.id             = item.ItemDetailId;
                tree.text           = item.ItemName;
                tree.value          = item.ItemValue;
                tree.parentId       = item.ParentId;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "formCategory";
                treeList.Add(tree);
            }
            foreach (FormModuleEntity item in formModuleData)
            {
                #region 部门
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id    = item.FrmId;
                tree.text  = item.FrmName;
                tree.value = item.FrmId;

                tree.parentId        = item.FrmCategory;
                tree.isexpand        = true;
                tree.complete        = true;
                tree.hasChildren     = hasChildren;
                tree.Attribute       = "Sort";
                tree.AttributeValue  = "form";
                tree.AttributeA      = "version";
                tree.AttributeValueA = item.Version;
                treeList.Add(tree);
                #endregion
            }
            //if (!string.IsNullOrEmpty(queryJson))
            //{
            //    treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
            //}
            return(Content(treeList.TreeToJson()));
        }