트리메뉴중에선 기능이 상당히 많은 오픈소스입니다.
데이타 타입은 html, json, xml등 거의대부분 지원합니다.
복잡한 기능을 구현하려면 jquery를 알고있는게 좋습니다.
홈페이지: http://www.jstree.com/
예제에선 _xml_nest.xml이란 데이타 파일을 읽어들이고,
노드 추가/삭제를 할 수 있습니다.
예제 페이지 소스
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jsTree v.1.0 - full featured demo</title>
<script type="text/javascript" src="_lib/jquery.js"></script>
<script type="text/javascript" src="_lib/jquery.cookie.js"></script>
<script type="text/javascript" src="_lib/jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.jstree.js"></script>
<style type="text/css">
html, body { margin:0; padding:0; }
body, td, th, pre, code, select, option, input, textarea { font-family:verdana,arial,sans-serif; font-size:10px; }
.demo, .demo input, .jstree-dnd-helper, #vakata-contextmenu { font-size:10px; font-family:Verdana; }
#container { width:780px; margin:10px auto; overflow:hidden; position:relative; }
#demo { width:auto; height:400px; overflow:auto; border:1px solid gray; }
#text { margin-top:1px; }
#alog { font-size:9px !important; margin:5px; border:1px solid silver; }
</style>
</head>
<body>
<div id="demo" class="demo"></div>
<div id="menu">
<button id="addFolder">add folder</button><br/>
<button id="addItem">add item</button><br/>
<button id="deleteItem">delete item</button><br/>
</div>
<script>
$(function () {
$("#demo").jstree({
"xml_data" : {
"ajax" : {
"url" : "_xml_nest.xml"
},
"xsl" : "nest"
},
"plugins" : [ "themes", "xml_data","ui","crrm"],
"ui" : {
// this makes the node with ID node_4 selected onload
"initially_select" : [ "pxml_6" ]
}
});
});
$(function(){
$("#demo").bind("create.jstree", function (event, data) {
data.rslt.obj.attr("id","testid");
alert(data.rslt.obj.attr("id"));
});
});
$(function(){
$('#menu button').click(function(){
switch(this.id){
case "addFolder":
//alert("addFolder");
//$("#demo").jstree("create", null, "last", { "attr" : { "rel" : "folder" } });
//$("#demo").jstree("create",-1,false,"CREATED NODE",false,true);
$("#demo").jstree("create","#pxml_5","last","CREATED NODE",false,true);
break;
case "addItem":
//alert("addItem");
$("#demo").jstree("create", null, "last", { "attr" : { "rel" : "default" } });
break;
case "deleteItem":
$("#demo").jstree("remove","#testid");
default:
break;
}
});
});
</script>
</body>
</html>
xml 데이타
<root>
<item id="pxml_1">
<content><name><![CDATA[Root node 1]]></name></content>
<item id="pxml_2">
<content><name><![CDATA[Child node 1]]></name></content>
</item>
<item id="pxml_3">
<content><name><![CDATA[zzzzzz]]></name></content>
</item>
<item id="pxml_4">
<content><name><![CDATA[Some other child node]]></name></content>
</item>
</item>
<item id="pxml_5">
<content><name><![CDATA[Root node 222]]></name></content>
</item>
<item id="pxml_6">
<content><name><![CDATA[menu2]]></name></content>
</item>
<item id="pxml_7">
<content><name><![CDATA[kkkkkk]]></name></content>
</item>
</root>