zTreeObj.updateNode.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeNode, checkTypeFlag)</span><span class="path">zTreeObj.</span>updateNode</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>Update node data. Primarily used to update the node's DOM.</p>
  10. <p class="highlight_red">1. Can update the attributes for display (e.g. 'name', 'target', 'url', 'icon',
  11. 'iconSkin', 'checked', 'nocheck'), do not update the other attributes. For example: If you need to
  12. expand the node, please use expandNode() method, do not modify the 'open' attribute.</p>
  13. <p class="highlight_red">2. Use updateNode() method of zTree can't trigger 'beforeCheck' or 'onCheck'
  14. callback function.</p>
  15. <p class="highlight_red">Please use zTree object to executing the method.</p>
  16. </div>
  17. </div>
  18. <h3>Function Parameter Descriptions</h3>
  19. <div class="desc">
  20. <h4><b>treeNode</b><span>JSON</span></h4>
  21. <p>JSON data object of the node which need to update.</p>
  22. <p class="highlight_red">Please ensure that this data object is an internal node data object in zTree.</p>
  23. <h4 class="topLine"><b>checkTypeFlag</b><span>Boolean</span></h4>
  24. <p>checkTypeFlag = true means: According to 'setting.check.chkboxType' attribute automatically check or
  25. uncheck the parent and child nodes.</p>
  26. <p>checkTypeFlag = false means: only check or uncheck this node, don't affect its parent and child
  27. nodes.</p>
  28. <p class="highlight_red">This parameter is valid when 'setting.check.enable = true' and
  29. 'setting.check.chkStyle = "checkbox"'</p>
  30. <p class="highlight_red">Don't affect the parent and child nodes which 'nocheck' attribute is true.</p>
  31. <h4 class="topLine"><b>Return </b><span>none</span></h4>
  32. <p>no return value</p>
  33. </div>
  34. <h3>Examples of function</h3>
  35. <h4>1. Modify the first selected node's name, and update it.</h4>
  36. <pre xmlns=""><code>var treeObj = $.fn.zTree.getZTreeObj("tree");
  37. var nodes = treeObj.getNodes();
  38. if (nodes.length>0) {
  39. nodes[0].name = "test";
  40. treeObj.updateNode(nodes[0]);
  41. }
  42. </code></pre>
  43. </div>
  44. </div>