C# Vue TreeSelect 的树形控件的节点加载问题,如何去掉节点前面的小三角.

C# Vue TreeSelect 的树形控件的节点加载问题,如何去掉节点前面的小三角.

主要是利用了C# List 的 dynamic 类型.


    public ActionResult AjaxLoadAllDepartments()
     {

         var tree = cache.GetCache<List<dynamic>>("AllDepartmentsTree");
         if (tree ==null)
         {
             var DB = new DbHelp.Base.DbBase<SysDepartmentInfo>();
             SysDepartmentInfo[] all = DB
                       .AsQueryable()
                       .Where(a=>a.UseFlag == 1)
                       .OrderBy(x => x.SortCode)
                       .ToArray();
             tree = GetChildMenu(all, "0");
             
             cache.SetCache("AllDepartmentsTree", tree);
         }

         return Json(new AjaxResponse() {
             Data = tree,
             Success =true
         });
     }

     /// 
     /// 获取子菜单
     /// 
     private List<dynamic> GetChildMenu(SysDepartmentInfo[] cacheAllDeptList, string ParentId)
     {
         var childs = new List<dynamic>();
         foreach (var item in cacheAllDeptList)
         {
             if (item.ParentDepartmentID== ParentId)
             {
                 var children = GetChildMenu(cacheAllDeptList, item.DepartmentID);
                 //dynamic node = new System.Dynamic.ExpandoObject();

                 if (children == null || children.Count == 0)
                 {
                     var node = new Vue_TreeSelectLeafNode();
                     node.id = item.DepartmentID;
                     node.label = item.DepartmentName;
                     node.children = children;//这样不会有个小三角
                     childs.Add(node);
                 } else {

                     var node = new Vue_TreeSelectNode();
                     node.id = item.DepartmentID;
                     node.label = item.DepartmentName;
                     node.children = children;//这样会有个小三角
                     childs.Add(node);
                 }
                
             }
         }
         return childs; 
     }

 }

 /// 
 /// 有子节点的分支节点
 /// 
 public class Vue_TreeSelectNode : Vue_TreeSelectLeafNode
 { 
     public List<dynamic> children { get; set; }  //有这个属性就会有小三角
 }

 
 /// 
 /// 叶子节点
 /// 
 public class Vue_TreeSelectLeafNode
 {
     /// 
     /// 
     /// 
     public string id { get; set; }//: 'a',

     /// 
     /// 标签
     /// 
     public string label { get; set; }

     public bool isDefaultExpanded { get; set; }
     public bool isDisabled { get; set; } 
 }

你可能感兴趣的:(net,vue)