/// <summary> /// /// </summary> /// <param name="ParentID"></param> /// <returns></returns> public List <JsonFunTree> GetSearchChildNodes(string ParentID) { List <JsonFunTree> list = new List <JsonFunTree>(); DataSet ds = new BllSysFun().GetTreeList("ParentID='" + ParentID + "'"); if (ds.Tables[0].Rows.Count > 0) { for (int b = 0; b < ds.Tables[0].Rows.Count; b++) { JsonFunTree model = new JsonFunTree(); model.id = ds.Tables[0].Rows[b]["id"].ToString(); model.parentId = ds.Tables[0].Rows[b]["parentId"].ToString(); model.text = ds.Tables[0].Rows[b]["text"].ToString(); model.iconCls = ds.Tables[0].Rows[b]["iconCls"].ToString(); model.pageUrl = ds.Tables[0].Rows[b]["PageUrl"].ToString(); model.className = ds.Tables[0].Rows[b]["ClassName"].ToString(); model.funSort = Convert.ToInt32(ds.Tables[0].Rows[b]["FunSort"]); model.expanded = true; model.IsSystem = Convert.ToBoolean(ds.Tables[0].Rows[b]["IsSystem"]); //是否系统定义 model.CreateTime = Convert.ToDateTime(ds.Tables[0].Rows[b]["CreateTime"]); model.leaf = true; model.children = GetSearchChildNodes(ds.Tables[0].Rows[b]["id"].ToString()); if (model.children.Count > 0) { model.leaf = false; } list.Add(model); } } return(list); }
//获取根节点 public List <JsonFunTree> GetChildCategoryNodes(DataSet parDs, DataTable ds) { DataView dv = parDs.Tables[0].DefaultView; List <JsonFunTree> list = new List <JsonFunTree>(); for (int i = 0; i < ds.Rows.Count; i++) { JsonFunTree model = new JsonFunTree(); model.id = ds.Rows[i]["id"].ToString(); model.parentId = ds.Rows[i]["parentId"].ToString(); model.text = ds.Rows[i]["text"].ToString(); model.expanded = false; model.leaf = true; //查询子节点 dv.RowFilter = "parentId='" + ds.Rows[i]["id"].ToString() + "'"; DataTable childSet = dv.ToTable(); if (childSet.Rows.Count > 0) { model.leaf = false; model.children = GetChildCategoryNodes(parDs, childSet); } list.Add(model); } return(list); }
/// <summary> /// 根据全部查询获取树形递归 /// </summary> /// <param name="parDs"></param> /// <returns></returns> public List <JsonFunTree> CategoryTreeNodes(DataSet parDs) { DataView dv = parDs.Tables[0].DefaultView; dv.RowFilter = "ParentID='0'";//树形默认根节点0 DataTable ds = dv.ToTable(); List <JsonFunTree> list = new List <JsonFunTree>(); for (int i = 0; i < ds.Rows.Count; i++) { JsonFunTree model = new JsonFunTree(); model.id = ds.Rows[i]["id"].ToString(); model.parentId = ds.Rows[i]["parentId"].ToString(); model.text = ds.Rows[i]["text"].ToString(); //model.Depth = int.Parse(ds.Rows[i]["Depth"].ToString()); model.expanded = false; model.leaf = true; //查询子节点 dv.RowFilter = "ParentID='" + ds.Rows[i]["id"].ToString() + "'"; DataTable childSet = dv.ToTable(); if (childSet.Rows.Count > 0) { model.leaf = false; model.children = CategoryChildNodes(parDs, childSet); } list.Add(model); } return(list); }
//获取根节点 public List <JsonFunTree> GetChildNodes(DataSet parDs, DataTable ds) { DataView dv = parDs.Tables[0].DefaultView; List <JsonFunTree> list = new List <JsonFunTree>(); for (int i = 0; i < ds.Rows.Count; i++) { JsonFunTree model = new JsonFunTree(); model.id = ds.Rows[i]["id"].ToString(); model.parentId = ds.Rows[i]["parentId"].ToString(); model.text = ds.Rows[i]["text"].ToString(); model.iconCls = ds.Rows[i]["iconCls"].ToString(); model.pageUrl = ds.Rows[i]["PageUrl"].ToString(); model.TypeId = int.Parse(ds.Rows[i]["TypeID"].ToString()); model.Status = int.Parse(ds.Rows[i]["Status"].ToString()); model.className = ds.Rows[i]["ClassName"].ToString(); model.funSort = Convert.ToInt32(ds.Rows[i]["FunSort"]); model.IsSystem = Convert.ToBoolean(ds.Rows[i]["IsSystem"]);//是否系统定义 model.expanded = false; model.leaf = true; model.CreateTime = Convert.ToDateTime(ds.Rows[i]["CreateTime"]); //查询子节点 dv.RowFilter = "ParentID='" + ds.Rows[i]["id"].ToString() + "'"; DataTable childSet = dv.ToTable(); if (childSet.Rows.Count > 0) { model.leaf = false; model.children = GetChildNodes(parDs, childSet); } list.Add(model); } return(list); }
/// <summary> /// 根据全部查询获取树形递归 /// </summary> /// <param name="parDs"></param> /// <returns></returns> public List <JsonFunTree> BrandTreeNodes(IList <ModSysQRCode> parDs) { List <JsonFunTree> list = new List <JsonFunTree>(); for (int i = 0; i < parDs.Count; i++) { JsonFunTree model = new JsonFunTree(); model.id = parDs[i].Id; model.parentId = "0"; model.text = parDs[i].Name; model.Depth = 0; model.expanded = false; model.leaf = true; model.leaf = true; list.Add(model); } return(list); }
public void GetSysDicByType(int Type) { List <ModSysDirc> jsonlist = new BllSysDirc().QueryToAll().Where(p => p.Type == Type && p.Status == (int)StatusEnum.正常).ToList(); List <JsonFunTree> list = new List <JsonFunTree>(); for (int i = 0; i < jsonlist.Count; i++) { JsonFunTree model = new JsonFunTree(); model.id = jsonlist[i].Id; model.parentId = "0"; model.text = jsonlist[i].Name; model.Depth = 0; model.expanded = false; model.leaf = true; model.leaf = true; list.Add(model); } WriteJsonToPage(JsonHelper.ToJson(list)); }
public List <JsonFunTree> getTree(List <JsonFunTree> r, DataRow[] select, DataTable mytab) { foreach (var myrow in select) { JsonFunTree m = new JsonFunTree(); m.id = myrow["id"].ToString(); m.text = myrow["text"].ToString(); m.parentId = myrow["parentId"].ToString(); m.expanded = true; m.leaf = true; DataRow[] dRow = mytab.Select("parentId='" + myrow["id"].ToString() + "'"); if (dRow.Count() > 0) { var children = new List <JsonFunTree>(); m.children = getTree(children, dRow, mytab); m.leaf = false; } r.Add(m); } return(r); }