org_chart.js 使用方法
1.引用css 2.引用js 3.ajax获得json数据
1 4. 2 $('#chart-container').orgchart({ 3 'data': json, 4 'nodeContent': 'm_name', 5 'nodeTitle': 'm_no'
6 });
1 json数据 2 [WebMethod] 4 public static string GetChart() 5 { 6 BLL.T_Member bll = new BLL.T_Member(); 7 Model.T_Member model = bll.GetModel(1); 8 List<Model.T_Member> all = bll.GetModelList(""); 9 10 Children(all, model); 11 string json = Newtonsoft.Json.JsonConvert.SerializeObject(model); 12 return json; 13 } 14 15 16 public static void Children(List<Model.T_Member> all, Model.T_Member curItem) 17 { 18 var subItems = all.Where(p=> p.m_forid == curItem.m_id).OrderBy(p=> p.m_forpositon).ToList(); 19 curItem.children = new List<Model.T_Member>(); 20 curItem.children.AddRange(subItems); 21 foreach (var subItem in subItems) 22 { 23 Children(all, subItem);//新闻1.1 24 } 25 }