setting.view.addDiyDom.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode)</span><span class="path">setting.view.</span>addDiyDom</h2>
  4. <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>用于在节点上固定显示用户自定义控件</p>
  9. <p class="highlight_red">1. 大数据量的节点加载请注意:在 addDiyDom 中针对每个节点 查找 DOM 对象并且添加新 DOM 控件,肯定会影响初始化性能;如果不是必须使用,建议不使用此功能</p>
  10. <p class="highlight_red">2. 属于高级应用,使用时请确保对 zTree 比较了解。</p>
  11. <p>默认值:null</p>
  12. </div>
  13. </div>
  14. <h3>Function 参数说明</h3>
  15. <div class="desc">
  16. <h4><b>treeId</b><span>String</span></h4>
  17. <p>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
  18. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  19. <p>需要显示自定义控件的节点 JSON 数据对象</p>
  20. </div>
  21. <h3>setting & function 举例</h3>
  22. <h4>1. 设置节点后面显示一个按钮</h4>
  23. <pre xmlns=""><code>var setting = {
  24. view: {
  25. addDiyDom: addDiyDom
  26. }
  27. };
  28. function addDiyDom(treeId, treeNode) {
  29. var aObj = $("#" + treeNode.tId + "_a");
  30. if ($("#diyBtn_"+treeNode.id).length>0) return;
  31. var editStr = "&lt;span id='diyBtn_space_" +treeNode.id+ "' &gt; &lt;/span&gt;"
  32. + "&lt;button type='button' class='diyBtn1' id='diyBtn_" + treeNode.id
  33. + "' title='"+treeNode.name+"' onfocus='this.blur();'&gt;&lt;/button&gt;";
  34. aObj.append(editStr);
  35. var btn = $("#diyBtn_"+treeNode.id);
  36. if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);});
  37. };
  38. ......</code></pre>
  39. </div>
  40. </div>