public ActionResult GetPostCheckTreeJson(string keyword) { var data = postBLL.GetAllList(); if (!string.IsNullOrEmpty(keyword)) { data = data.TreeWhere(t => t.FullName.Contains(keyword), ""); } var treeList = new List <TreeEntity>(); string companyname = ""; int num = 0; foreach (RoleEntity item in data) { TreeEntity tree = new TreeEntity(); if (companyname != item.OrganizeId) { num++; TreeEntity tree1 = new TreeEntity(); companyname = item.OrganizeId; tree1.id = num + ""; tree1.text = companyname; tree1.value = companyname; tree1.isexpand = true; tree1.complete = true; tree1.hasChildren = true; tree1.parentId = "0"; tree1.img = "fa fa-home"; treeList.Add(tree1); } tree.id = item.RoleId; tree.text = item.FullName; tree.value = item.RoleId; tree.isexpand = true; tree.complete = true; tree.hasChildren = false; tree.parentId = num + ""; tree.showcheck = true; tree.img = "fa fa-user"; tree.Attribute = "mytype"; tree.AttributeValue = "Post"; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }