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>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>This function used to display the custom control on the node.</p>
  9. <p class="highlight_red">1. If you have huge node data, please note: this function will affect the initialization performance. If not required, it is recommended not to use this function.</p>
  10. <p class="highlight_red">2. This function is an advanced application, please make sure that a better understanding of zTree before you use it.</p>
  11. <p>Default: null</p>
  12. </div>
  13. </div>
  14. <h3>Function Parameter Descriptions</h3>
  15. <div class="desc">
  16. <h4><b>treeId</b><span>String</span></h4>
  17. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  18. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  19. <p>JSON data object of the node which display the custom control.</p>
  20. </div>
  21. <h3>Examples of setting & function</h3>
  22. <h4>1. Display button in all nodes.</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>