资源描述:
《dtree+jquery动态生成树节点例子《新手可参考》》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Dtree+Jquery动态生成树节点例子《新手可参考》jQueryJavaScriptJSPAjaxCSSDtree+Jquery动态生成树节点.最近有朋友问我一个动态生成树怎么做.后来就用Dtreejs组件和Jquery实现了一个demo给他.现在贴出来给初学者做些参考.1.先来介绍一下.dtree的用法.(我引用了以前我收集的一篇文章.还比较详细,出处不记得啦).文章下面会附带dtree用法的例子.Dtree目录树的总结一:函数1:页面中tree.add(id,pid,name,url,title,target,i
2、con,iconOpen,open);参数说明:id:节点自身的idpid:节点的父节点的idname:节点显示在页面上的名称url:节点的链接地址title:鼠标放在节点上所出现的提示信息target:节点链接所打开的目标frame(如框架目标mainFrame,_blank,_self类)icon:节点关闭时的显示图片的路径iconOpen:节点打开时的显示图片的路径open:布尔型,节点是否打开(默认为false)注:open项:顶级节点一般采用true,即pid是-1的节点2:dtree.js文件中约87-113
3、行是一些默认图片的路径,注意要指对。二:页面中的书写1:默认值的书写规则(从左至右,依次省略)即tree.add(id,pid,name,url);后面5个参数可以省略2:有间隔时的默认值(如存在第6个参数,但第5个参数想用默认值)即tree.add(id,pid,name,url,"",target);必须这样写3:样式表(1):可以将dtree.css中的样式附加到你的应用中的主css中,如a.css(2):也可以同时引用dtree.css与a.css两个文件,但前提条件是两个css文件中不能有重复的样式Html代码
4、4:页面代码书写的位置是:一般写在表格的td之中Javascript代码<
5、scripttype="text/javascript">tree=newdTree('tree');tree.add("1","-1","京津","","","","","",true);tree.add("11","1","A","","","","","",true);tree.add("110","11","A-1","content.jsp?moduleName=XXX","","mainFrame");tree.add("111","11","A-2","javascript:void(0)","","链接在
6、哪里显示");tree.add("112","11","A-3","javascript:void(0)","","mainFrame");tree.add("113","11","A-4","/.jsp","","mainFrame");tree.add("114","11","A-5","/.jsp","","mainFrame");tree.add("115","11","A-6","/.jsp","","mainFrame");tree.add("12","1","B","","","","","",true);
7、tree.add("121","12","B-1","javascript:调用本页内的js函数","","mainFrame");tree.add("122","12","B-2");tree.add("13","1","C","","","","","",true);tree.add("131","13","C-1","javascript:void(0)","","mainFrame");tree.add("132","13","C-2","javascript:void(0)","","mainFrame");t
8、ree.add("133","13","C-3","javascript:void(0)","","mainFrame");tree.add("14","1","D","","","","","",true);tree.add("141","14","D-1","javascript:void(0)","","mai