setting.view.nodeClasses.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>JSON / Function(treeId, treeNode)</span><span class="path">setting.view.</span>nodeClasses</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>Use className to set text style, only applies to &lt;A&gt; object in the node DOM. (Decoupling CSS from JavaScript)</p>
  9. <p>Default: {add: [], remove: []}</p>
  10. <p class="highlight_red">v3.5.43+</p>
  11. </div>
  12. </div>
  13. <h3>JSON Format</h3>
  14. <div class="desc">
  15. <p>add: Array, The className collection to be added. e.g. <span class="highlight_red">{add: ['highlight']}</span></p>
  16. <p>remove: Array, The className collection to be removed. e.g. <span class="highlight_red">{remove: ['highlight']}</span></p>
  17. </div>
  18. <h3>Function Parameter Descriptions</h3>
  19. <div class="desc">
  20. <h4><b>treeId</b><span>String</span></h4>
  21. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  22. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  23. <p>JSON data object of the node which use the personalized text style</p>
  24. <h4 class="topLine"><b>Return </b><span>JSON</span></h4>
  25. <p>Return value is same as 'JSON Format'. e.g. <span class="highlight_red">{add: ['highlight'], remove: ['hide']}</span></p>
  26. </div>
  27. <h3>Examples of setting & function</h3>
  28. <h4>1. Set the node name's color to red</h4>
  29. <pre xmlns=""><code><style>.ztree li > a.highlight { color: red; }</style>
  30. var setting = {
  31. view: {
  32. nodeClasses : {add: ['highlight']}
  33. }
  34. };</code></pre>
  35. <h4>2. Remove the node name's special className: highlight</h4>
  36. <pre xmlns=""><code>var setting = {
  37. view: {
  38. nodeClasses : {remove: ['highlight']}
  39. }
  40. };</code></pre>
  41. <h4>3. Set the root node name's color to red</h4>
  42. <pre xmlns=""><code>function setNodeClasses(treeId, treeNode) {
  43. return treeNode.level == 0 ? {add: ['highlight']} : {remove: ['highlight']};
  44. };
  45. var setting = {
  46. view: {
  47. nodeClasses: setNodeClasses
  48. }
  49. };</code></pre>
  50. </div>
  51. </div>