[英]how to create dynamic tree structure with list of string paths using javascript
I have a list of strings with are paths to some file with "/" separator that are available to my jsp/html page . 我有一个字符串列表,这些字符串是指向带有“ /”分隔符的文件的路径,这些路径可用于我的jsp / html页面。 ie
即
d1/d2/d3/file1.c
d1/d2/d3/file2.java
d1/d2/file3.jsp
d1/d2/file4.asp
d1/d2/d3/d4/file4.asp
d11/d22/d33/file5.txt
The above list of string paths are available to my page. 上面的字符串路径列表可用于我的页面。 I need to make a dynamic tree structre with above data in below tree structure using javascript.
我需要使用javascript在下面的树结构中使用上面的数据制作一个动态树结构。
+d1/d2/
file3.jsp
file4.asp
+d1/d2/d3/
file1.c
file2.java
+d1/d2/d3/d4/
file4.asp
+d11/d22/d33/
file5.txt
When I click on the common path like +di/d2 it should expand to show all the files under that directory , and when again click on it should hide the child files. 当我单击+ di / d2之类的通用路径时,它应该展开以显示该目录下的所有文件,而再次单击它时,则应隐藏子文件。 Simmilarly for all other nodes.
类似地,用于所有其他节点。
Since you have no code to show us, I'm not going to write it all for you. 由于您没有可向我们展示的代码,因此我不会为您编写所有代码。 Just an overview, to tell you the method, you'll have to write your own code:
只是概述,要告诉您该方法,您必须编写自己的代码:
For reference: Javascript building tree hierarchy 供参考: Javascript构建树层次结构
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.