标签:数据 children img parent ott and 标签 php block
x
本来想自己敲一个zTree的例子的>>>
但是一想zTree文档做的这么好,直接拷贝过来一个得了...
哈哈>>>
<!DOCTYPE html> <html> <head> <title> ZTREE DEMO - addHoverDom / removeHoverDom / addDiyDom</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="diydom_data/demo.css" type="text/css"> <link rel="stylesheet" href="diydom_data/zTreeStyle.css" type="text/css"> <script type="text/javascript" src="diydom_data/jquery-1.js"></script> <script type="text/javascript" src="diydom_data/jquery.js"></script> <script type="text/javascript" src="diydom_data/jquery_002.js"></script> <script type="text/javascript" src="diydom_data/jquery_003.js"></script> <style type="text/css"> .ztree li span.demoIcon { padding: 0 2px 0 10px; } .ztree li span.button.icon01 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/3.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } .ztree li span.button.icon02 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/4.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } .ztree li span.button.icon03 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/5.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } .ztree li span.button.icon04 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/6.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } .ztree li span.button.icon05 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/7.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } .ztree li span.button.icon06 { margin: 0; background: url(../../../css/zTreeStyle/img/diy/8.png) no-repeat scroll 0 0 transparent; vertical-align: top; *vertical-align: middle; } </style> </head> <body> <h1>添加自定义控件</h1> <h6>[ 文件路径: super/diydom.html ]</h6> <div class="content_wrap"> <div class="zTreeDemoBackground left"> <ul id="treeDemo" class="ztree" style="-moz-user-select: none;"><li id="treeDemo_1" class="level0" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_1_switch" title="" class="button level0 switch roots_open" treenode_switch=""></span><a id="treeDemo_1_a" class="level0" treenode_a="" onclick="" target="_blank" style="" title="hover事件显示控件"><span id="treeDemo_1_ico" title="" treenode_ico="" class="button ico_open" style=""></span><span id="treeDemo_1_span" class="node_name">hover事件显示控件</span></a><ul id="treeDemo_1_ul" class="level0 line" style="display:block"><li id="treeDemo_2" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_2_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_2_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="按钮1"><span id="treeDemo_2_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_2_span" class="node_name">按钮1</span></a></li><li id="treeDemo_3" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_3_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_3_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="按钮2"><span id="treeDemo_3_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_3_span" class="node_name">按钮2</span></a></li><li id="treeDemo_4" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_4_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_4_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="下拉框"><span id="treeDemo_4_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_4_span" class="node_name">下拉框</span></a></li><li id="treeDemo_5" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_5_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_5_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="文本1"><span id="treeDemo_5_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_5_span" class="node_name">文本1</span></a></li><li id="treeDemo_6" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_6_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_6_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="文本2"><span id="treeDemo_6_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_6_span" class="node_name">文本2</span></a></li><li id="treeDemo_7" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_7_switch" title="" class="button level1 switch bottom_docu" treenode_switch=""></span><a id="treeDemo_7_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="超链接"><span id="treeDemo_7_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_7_span" class="node_name">超链接</span></a></li></ul></li><li id="treeDemo_8" class="level0" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_8_switch" title="" class="button level0 switch bottom_open" treenode_switch=""></span><a id="treeDemo_8_a" class="level0" treenode_a="" onclick="" target="_blank" style="" title="始终显示控件"><span id="treeDemo_8_ico" title="" treenode_ico="" class="button ico_open" style=""></span><span id="treeDemo_8_span" class="node_name">始终显示控件</span></a><ul id="treeDemo_8_ul" class="level0 " style="display:block"><li id="treeDemo_9" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_9_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_9_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="按钮1"><span id="treeDemo_9_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_9_span" class="node_name">按钮1</span><span class="demoIcon" id="diyBtn_21" title="按钮1" onfocus="this.blur();"><span class="button icon01"></span></span></a></li><li id="treeDemo_10" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_10_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_10_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="按钮2"><span id="treeDemo_10_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_10_span" class="node_name">按钮2</span></a><span class="demoIcon" id="diyBtn_22" title="按钮2" onfocus="this.blur();"><span class="button icon02"></span></span></li><li id="treeDemo_11" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_11_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_11_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="下拉框"><span id="treeDemo_11_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_11_span" class="node_name">下拉框</span></a><select class="selDemo" id="diyBtn_23"><option value="1" selected="selected">1</option><option value="2">2</option><option value="3">3</option></select></li><li id="treeDemo_12" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_12_switch" title="" class="button level1 switch center_docu" treenode_switch=""></span><a id="treeDemo_12_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="文本"><span id="treeDemo_12_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_12_span" class="node_name">文本</span></a><span id="diyBtn_24">Text Demo...</span></li><li id="treeDemo_13" class="level1" tabindex="0" hidefocus="true" treenode=""><span id="treeDemo_13_switch" title="" class="button level1 switch bottom_docu" treenode_switch=""></span><a id="treeDemo_13_a" class="level1" treenode_a="" onclick="" target="_blank" style="" title="超链接"><span id="treeDemo_13_ico" title="" treenode_ico="" class="button ico_docu" style=""></span><span id="treeDemo_13_span" class="node_name">超链接</span></a><a id="diyBtn1_25" onclick="alert(1);return false;">链接1</a><a id="diyBtn2_25" onclick="alert(2);return false;">链接2</a></li></ul></li></ul> </div> <div> <input type="button" id="id_update_text" value="更新文本>>>" onclick="test()" /> </div> <div class="right"> <ul class="info"> <li class="title"> <h2>1、实现方法说明</h2> <ul class="list"> <li>利用 setting.view.addHoverDom / removeHoverDom / addDiyDom 这几个参数的配置可以很容易的实现自定义控件的功能</li> <li class="highlight_red">添加自定义控件,请务必掌握 zTree 节点对象的命名规则,以保证正常添加 DOM 控件</li> <li class="highlight_red">如果添加标准的 select / checkbox / radio 等,请注意适当调整 zTree 的布局 css,保证 zTree 能正常显示</li> </ul> </li> <li class="title"> <h2>2、setting 配置信息说明</h2> <ul class="list"> <li>使用 setting.view.addHoverDom / removeHoverDom / addDiyDom 属性,详细请参见 API 文档中的相关内容</li> </ul> </li> <li class="title"> <h2>3、treeNode 节点数据说明</h2> <ul class="list"> <li>对 节点数据 没有特殊要求,用户可以根据自己的需求添加自定义属性</li> </ul> </li> </ul> </div> </div> <script type="text/javascript"> <!-- var IDMark_Switch = "_switch", IDMark_Icon = "_ico", IDMark_Span = "_span", IDMark_Input = "_input", IDMark_Check = "_check", IDMark_Edit = "_edit", IDMark_Remove = "_remove", IDMark_Ul = "_ul", IDMark_A = "_a"; var setting = { view: { addHoverDom: addHoverDom, removeHoverDom: removeHoverDom, addDiyDom: addDiyDom } }; var zNodes =[ {id:1, name:"hover事件显示控件", open:true, children:[ {id:11, name:"按钮1"}, {id:12, name:"按钮2"}, {id:13, name:"下拉框"}, {id:141, name:"文本1"}, {id:142, name:"文本2"}, {id:15, name:"超链接"} ]}, {id:2, name:"始终显示控件", open:true, children:[ {id:21, name:"按钮1"}, {id:22, name:"按钮2"}, {id:23, name:"下拉框"}, {id:24, name:"文本"}, {id:25, name:"超链接"} ]} ]; function addHoverDom(treeId, treeNode) { if (treeNode.parentNode && treeNode.parentNode.id!=1) return; var aObj = $("#" + treeNode.tId + IDMark_A); if (treeNode.id == 11) { if ($("#diyBtn_"+treeNode.id).length>0) return; var editStr = "<span id=‘diyBtn_space_" +treeNode.id+ "‘ > </span><span class=‘button icon03‘ id=‘diyBtn_" +treeNode.id+ "‘ title=‘"+treeNode.name+"‘ onfocus=‘this.blur();‘></span>"; aObj.append(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);}); } else if (treeNode.id == 12) { if ($("#diyBtn_"+treeNode.id).length>0) return; var editStr = "<span class=‘button icon04‘ id=‘diyBtn_" +treeNode.id+ "‘ title=‘"+treeNode.name+"‘ onfocus=‘this.blur();‘></span>"; aObj.after(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);}); } else if (treeNode.id == 13) { if ($("#diyBtn_"+treeNode.id).length>0) return; var editStr = "<span id=‘diyBtn_space_" +treeNode.id+ "‘ > </span><select class=‘selDemo ‘ id=‘diyBtn_" +treeNode.id+ "‘><option value=1>1</option><option value=2>2</option><option value=3>3</option></select>"; aObj.after(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("change", function(){alert("diy Select value="+btn.attr("value")+" for " + treeNode.name);}); } else if (treeNode.id == 141) { if ($("#diyBtn_"+treeNode.id).length>0) return; var editStr = "<span class=‘test‘ id=‘diyBtn_" +treeNode.id+ "‘>Text Demo...</span>"; aObj.append(editStr); } else if (treeNode.id == 142) { if ($("#diyBtn_"+treeNode.id).length>0) return; var editStr = "<span id=‘diyBtn_" +treeNode.id+ "‘>Text Demo...</span>"; aObj.after(editStr); } else if (treeNode.id == 15) { if ($("#diyBtn1_"+treeNode.id).length>0) return; if ($("#diyBtn2_"+treeNode.id).length>0) return; var editStr = "<a id=‘diyBtn1_" +treeNode.id+ "‘ onclick=‘alert(1);return false;‘ style=‘margin:0 0 0 5px;‘>链接1</a>" + "<a id=‘diyBtn2_" +treeNode.id+ "‘ onclick=‘alert(2);return false;‘ style=‘margin:0 0 0 5px;‘>链接2</a>"; aObj.append(editStr); } } function removeHoverDom(treeId, treeNode) { if (treeNode.parentTId && treeNode.getParentNode().id!=1) return; if (treeNode.id == 15) { $("#diyBtn1_"+treeNode.id).unbind().remove(); $("#diyBtn2_"+treeNode.id).unbind().remove(); } else { $("#diyBtn_"+treeNode.id).unbind().remove(); $("#diyBtn_space_" +treeNode.id).unbind().remove(); } } function addDiyDom(treeId, treeNode) { if (treeNode.parentNode && treeNode.parentNode.id!=2) return; var aObj = $("#" + treeNode.tId + IDMark_A); if (treeNode.id == 21) { var editStr = "<span class=‘demoIcon‘ id=‘diyBtn_" +treeNode.id+ "‘ title=‘"+treeNode.name+"‘ onfocus=‘this.blur();‘><span class=‘button icon01‘></span></span>"; aObj.append(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);}); } else if (treeNode.id == 22) { var editStr = "<span class=‘demoIcon‘ id=‘diyBtn_" +treeNode.id+ "‘ title=‘"+treeNode.name+"‘ onfocus=‘this.blur();‘><span class=‘button icon02‘></span></span>"; aObj.after(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);}); } else if (treeNode.id == 23) { var editStr = "<select class=‘selDemo‘ id=‘diyBtn_" +treeNode.id+ "‘><option value=1>1</option><option value=2>2</option><option value=3>3</option></select>"; aObj.after(editStr); var btn = $("#diyBtn_"+treeNode.id); if (btn) btn.bind("change", function(){alert("diy Select value="+btn.attr("value")+" for " + treeNode.name);}); } else if (treeNode.id == 24) { var editStr = "<span id=‘diyBtn_" +treeNode.id+ "‘>Text Demo...</span>"; aObj.after(editStr); } else if (treeNode.id == 25) { var editStr = "<a id=‘diyBtn1_" +treeNode.id+ "‘ onclick=‘alert(1);return false;‘>链接1</a>" + "<a id=‘diyBtn2_" +treeNode.id+ "‘ onclick=‘alert(2);return false;‘>链接2</a>"; aObj.after(editStr); } } ///主要是这段代码>>>很容易>>就是一个思路>>>哈哈>>>刚开始一直再查找zTree 的文档>>>没找到,后来一看源码才想到这么简单的问题>>>那时候已经进了zTree的圈出不来了>>> function test() { //alert("xx"); //要更新的节点>>>id var test_id = 24; var z_tree = $.fn.zTree.getZTreeObj("treeDemo"); var update_node = z_tree.getNodesByParam("id", test_id)[0];; update_node.name = ">" + Math.floor(Math.random() * 10) + ">"; //updateNode不可以更新自定义标签>>>毕竟自定义的>>> z_tree.updateNode(update_node); console.log(update_node); //这里可以直接用文本的id = "diyBtn_24"来更新>>>我遇上的情况这种文本比较多.通过name或者class来控制的>>>.. $("#" + update_node.tId).find("span").last().text(">" + Math.floor(Math.random() * 10) + ">"); } $(document).ready(function(){ $.fn.zTree.init($("#treeDemo"), setting, zNodes); //触发>>>更新>>> //$("#id_update_text").off("click"); //$("#id_update_text").on("click", function () { //}) }); //--> </script> </body> </html>
思路很简单>>>
但是刚开始陷入了zTree的文档里面了{想从里面找到接口>>>}
后来跳出来一看这么简单的问题>>>
下面贴上我拷贝zTree官网的demo↓文件>>>好吧,找到怎么上传文件再贴 /手动尴尬
x
标签:数据 children img parent ott and 标签 php block
原文地址:http://www.cnblogs.com/love-zf/p/7003868.html