日期:2014-05-16 浏览次数:20556 次
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery.tree.js"></script>
<script type="text/javascript" language="javascript">
  <!--  
    	$(function () { 
    		$.ajaxSetup({cache:false});//ajax调用不使用缓存
    		$("#vcsTree").tree({//创建树开始
    			  data : { 
    				type : "json",//类型为json
    				async : true,//动态操作
    				opts : {
    					method : "get", 
    					url : "async_json_data2.json"
    				}
    			 },//end data
    			 ui:{
    				 theme_name : "classic"
    			 },
    			 lang:{   
				 loading : "目录加载中……"  
			 }, 
			 rules : {
			 	type_attr	: "rel",     //设置节点类型
				valid_children : "root"  // 只有root节点才能作为顶级结点
			},
    			 types :{
    			 	"default" : {
    			 		clickable : true,
    			 		draggable : false    //设置节点不可拖拽
    			 	},
     			"root" : {
					valid_children : "folder", //设置下级节点类型,可是数组
					icon : { 
						image : "root.png"//设置当前节点icon图片,路径自己决定
					}
			 	},
			   "folder" : {
					valid_children : "leaf",
					icon : { 
						image : "folder.png"
					}
				},
				"leaf" : {
					valid_children : "none",
					icon : { 
						image : "leaf.png"
					}
				}
    			 }	    
    		});
    	});
   //-->
</script>
<div id="container"> 
		<h2 class="title">JsTree</h2>
		<div id="vcsTree"></div>			
</div>
Already fixed it with some jquery code:
instead of 
//jstree的types设置 ,和上面的代码并无多大区别,只是图片方式和jstree的提取方式是一样的,从一张png图片分割出自己想要的部分(个人说法)。
types : {
	"default" : { icon : { image : 'icon.png', position : '0 0' } }
	"root" : { icon : { image : 'icon.png', position : '-16px 0' } }
	"folder" : { icon : { image : 'icon.png', position : '-32px 0' } }
	"page" : { icon : { image : 'icon.png', position : '-32px 0' } }
}
//注释1 ,放在tree初始化代码后
I wrote (after initilization tree)
$("li[rel='root'] > a ins").addClass("root");
$("li[rel='folder'] > a ins").addClass("folder");
$("li[rel='page'] > a ins").addClass("page");
//注释2 ,添加在style.css文件内
and in style.css
.tree-classic li.open a ins.root, .tree-classic li.open a ins.folder, .tree-classic
li.open a ins.page
{background-image:url('icons.png');}
.tree-classic li.open a ins.root{background-position:0 -48px;}
.tree-classic li.open a ins.folder{background-position:0 0;}
.tree-classic li.open a ins.page{background-position:-16px 0;}
