/// <summary> /// 递归添加子节点 /// </summary> /// <param name="cRow"></param> private void BuildSubTree(DataRow cRow) { var i = 0; _stringBuilder.Append(",\"children\":["); foreach (var iRow in cRow.GetChildRows("NodeRelation")) { if (i != 0) { _stringBuilder.Append(","); } var text = iRow["AreaName"].ToString().Trim(); var no = iRow["AreaId"].ToString().Trim(); var href = Request.QueryString["menu"] + "?AreaId=" + no; //_stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }"); if (iRow.GetChildRows("NodeRelation").Length <= 0) { _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"icon\": \"jstree-iconla\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }"); } else { _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }"); } i++; BuildSubTree(iRow); _stringBuilder.Append("}"); } List<SqlParameter> parameters = new List<SqlParameter>(); var parameter = new SqlParameter("@AreaId", DbType.AnsiString) { Value = cRow["AreaId"] }; parameters.Add(parameter); var dt = new OrgOrganize().GetList(" AreaId=@AreaId and OrgType=5 and Status=1 ", parameters).Tables[0]; if (dt.Rows.Count > 0) { var k = 0; for (int j = 0; j < dt.Rows.Count; j++) { if (i != 0 || k != 0) { _stringBuilder.Append(","); } var text = dt.Rows[j]["OrgName"].ToString().Trim(); var no = dt.Rows[j]["OrgId"].ToString().Trim(); var href = Request.QueryString["menu"] + "?OId=" + no; _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"icon\": \"jstree-iconWS\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }"); k++; _stringBuilder.Append("}"); } } _stringBuilder.Append("]"); }