setting.view.addDiyDom.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode)</span><span class="path">setting.view.</span>addDiyDom</h2>
  4. <h3>Overview<span class="h3_info">[ depends on <span
  5. class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
  6. <div class="desc">
  7. <p></p>
  8. <div class="longdesc">
  9. <p>This function used to display the custom control on the node.</p>
  10. <p class="highlight_red">1. If you have huge node data, please note: this function will affect the
  11. initialization performance. If not required, it is recommended not to use this function.</p>
  12. <p class="highlight_red">2. This function is an advanced application, please make sure that a better
  13. understanding of zTree before you use it.</p>
  14. <p>Default: null</p>
  15. </div>
  16. </div>
  17. <h3>Function Parameter Descriptions</h3>
  18. <div class="desc">
  19. <h4><b>treeId</b><span>String</span></h4>
  20. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  21. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  22. <p>JSON data object of the node which display the custom control.</p>
  23. </div>
  24. <h3>Examples of setting & function</h3>
  25. <h4>1. Display button in all nodes.</h4>
  26. <pre xmlns=""><code>var setting = {
  27. view: {
  28. addDiyDom: addDiyDom
  29. }
  30. };
  31. function addDiyDom(treeId, treeNode) {
  32. var aObj = $("#" + treeNode.tId + "_a");
  33. if ($("#diyBtn_"+treeNode.id).length>0) return;
  34. var editStr = "&lt;span id='diyBtn_space_" +treeNode.id+ "' &gt; &lt;/span&gt;"
  35. + "&lt;button type='button' class='diyBtn1' id='diyBtn_" + treeNode.id
  36. + "' title='"+treeNode.name+"' onfocus='this.blur();'&gt;&lt;/button&gt;";
  37. aObj.append(editStr);
  38. var btn = $("#diyBtn_"+treeNode.id);
  39. if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);});
  40. };
  41. ......</code></pre>
  42. </div>
  43. </div>