jquery插件ztree的总结

来源:转载

jquery插件ztree的总结,有需要的朋友可以参考下。

zTree v3.5.18 API 文档:

http://www.ztree.me/v3/api.php

jquery-zTree引入的工具包:

http://download.csdn.net/detail/simplxs/9179761

引入js:

<link rel="stylesheet" href="<%=path%>/jquery-zTree/css/demo.css" type="text/css"><link rel="stylesheet" href="<%=path%>/jquery-zTree/css/zTreeStyle/zTreeStyle.css" type="text/css"><script type="text/javascript" src="<%=path%>/jquery-zTree/js/jquery-1.4.4.min.js"></script><script type="text/javascript" src="<%=path%>/jquery-zTree/js/jquery.ztree.core-3.5.js"></script><script type="text/javascript" src="<%=path%>/jquery-zTree/js/jquery.ztree.excheck-3.5.js"></script><script type="text/javascript" src="<%=path%>/jquery-zTree/js/jquery.ztree.exedit-3.5.js"></script>

js代码:

var setting = { data: { simpleData: { enable: true } } ,async: { enable: true, url:"<%=path %>/包/类!方法.action", autoParam:["id", "name", "level"], //传参 otherParam:{"otherParam":"zTreeAsyncTest"}, dataFilter: filter //获取数据执行},callback:{ onCheck: zTreeOnCheck, onAsyncError: zTreeOnAsyncError //加载错误的fun } }; //数据过滤function filter(treeId, parentNode, childNodes) { if (!childNodes) return null; var child=eval('('+childNodes.returnArray+')');//将数据转换成数组对象for (var i=0, l=child.length; i<l; i++) { child[i].name = child[i].name.replace('',''); } return child; } //异步加载错误提示function zTreeOnAsyncError(){alert("加载子菜单错误,请联系管理员处理"); }//鼠标点击事件function zTreeOnCheck(event, treeId, treeNode) {//alert(treeNode.tId + ", " + treeNode.name + "," + treeNode.checked);};//根节点数据var rootNodes=[{id:'0',pId:'',name:"第一节点",level:"0",nodeType:'root',isParent:true,iconSkin:"rootIcon"}, {id:'1',pId:'',name:"第二节点",level:"0",nodeType:'root',isParent:true,iconSkin:"rootIcon"}, {id:'2',pId:'',name:"第三节点",level:"0",nodeType:'root',isParent:true,iconSkin:"rootIcon"}]; $(document).ready(function(){ $.fn.zTree.init($("#tree"), setting, rootNodes); }); 

Html代码:

<div class="content_wrap" style="float: left;"> <div class="zTreeDemoBackground left"> <ul id="tree" class="ztree"></ul> </div> </div> 

注:zTree参数为数组,传值严格按照rootNodes。详细参照zTree API文档。

此为本人第一次用zTree插件的一些总结,如有问题,烦请大神门指出。

版权声明:本文为博主原创文章,未经博主允许不得转载。



分享给朋友:
您可能感兴趣的文章:
随机阅读: