最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
详解Jquery EasyUI tree 的异步加载(遍历指定文件夹,根据文件夹内的文件生成tree)
时间:2022-06-25 17:15:14 编辑:袖梨 来源:一聚教程网
Jquery EasyUI tree 的异步加载(遍历指定文件夹,根据文件夹内的文件生成tree)具体代码如下:
代码如下 | 复制代码 |
privatevoidSMT(HttpContext context) { stringSqlConnection82 = System.Configuration.ConfigurationManager.AppSettings["LocalConnectionString"]; stringpath = context.Server.MapPath(@"~/CISWeb/SMT_SOP"); stringid =string.Empty; List if(filesNameList.Count > 0) context.Response.Write(ListToJson(filesNameList,id)); else { context.Response.Write("0"); } } /// /// 范围指定目录下的 文件夹/文件 数量 /// /// /// privatestaticList { DirectoryInfo SMT_SOP =newDirectoryInfo(path); List DirectoryInfo[] allDir = SMT_SOP.GetDirectories();//获取文件夹数量 foreach(DirectoryInfo dinallDir) { allFileList.Add("0|"+ d.Name); } FileInfo[] allFile = SMT_SOP.GetFiles();//获取文件数量 foreach(FileInfo fiinallFile) { allFileList.Add("1|"+ fi.Name); } returnallFileList; } /// /// 遍历指定文件夹,根据文件夹内的文件返回JSON /// /// /// 第一次调用这个方法的时候,id="" /// publicstringListToJson(List { StringBuilder sb2 =newStringBuilder(); sb2.Append("["); for(inti = 0; i < filesNameList.Count; i++) { if(filesNameList[i].ToString().Split('|')[0] =="0") { sb2.Append("{ "id":"+id+ (i + 1).ToString() +","text":""+ filesNameList[i].ToString().Split('|')[1] +"","state":"closed","children": ["); sb2.Append("]},"); } else { sb2.Append("{"id":"+id + (i + 1).ToString() +","text":""+ String.Format(filesNameList[i].ToString().Split('|')[1]) +""},"); }
} sb2.Remove(sb2.Length - 1, 1); sb2.Append("]"); returnsb2.ToString(); } |
前台
代码如下 | 复制代码 |
$.ajax({ type:"post", url:"../../ajax/Handler.ashx?action=SMT", data: {}, success:function(result) { $("#menuDiv").dialog("open");//jQuery UI中的模态窗口 vartreeData = eval(result); $("#tt").tree({ data: treeData}) } }) |
相关文章
- Binance.US已上线VIRTUAL 04-30
- binance官网电脑下载_binance苹果版下载地址V2.57.7 04-30
- 比特币交易量最大的交易所是哪个?全球最大的比特币交易平台排名 04-30
- 奥比岛梦想国度卡死闪退有哪些解决方法 04-30
- DNF手游骨戒在哪个位置 04-30
- 回望羊驼:当利空成为短暂的财富密码 04-30