c# 格式化easyui tree
?
? ? ? ?public ActionResult Index() ? ? ? public class b ?public static void GetTree(EasyUIJsonTree parent,IList<Trees> list,int? parentID = 0)??????? {??????????? var query = list.Where(m => m.pid == parentID);??????????? if (query.Any())??????????? {??????????????? if (parent.children == null)??????????????? {??????????????????? parent.children = new List<EasyUIJsonTree>();??????????????? }??????????????? foreach (Trees mv in query)??????????????? {??????????????????? EasyUIJsonTree child = new EasyUIJsonTree()??????????????????? {??????????????????????? id = mv.id.ToString(),??????????????????????? text = mv.text,??????????????????????? //attributes = new { Url = mv.Url }??????????????????? };??????????????????? parent.children.Add(child);??????????????????? b.GetTree(child,list,mv.id);??????????????? }??????????? }??????? }??? }??? public class EasyUIJsonTree??? {??????? public string id { get; set; }??????? public string text { get; set; }??????? //public string iconCls { get; set; }??????? public IList<EasyUIJsonTree> children { get; set; }??????? public object attributes { get; set; }??? } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |