zTreeObj.moveNode.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(targetNode, treeNode, moveType, isSilent)</span><span class="path">zTreeObj.</span>moveNode</h2>
  4. <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.exedit</span> js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>Move the node</p>
  9. <p class="highlight_red">Please use zTree object to executing the method.</p>
  10. </div>
  11. </div>
  12. <h3>Function Parameter Descriptions</h3>
  13. <div class="desc">
  14. <h4><b>targetNode</b><span>JSON</span></h4>
  15. <p>JSON data object of the node which will be target.</p>
  16. <p class="highlight_red">If move the node to root node, please set the 'targetNode' to null.</p>
  17. <p class="highlight_red">Please ensure that this data object is an internal node data object in zTree.</p>
  18. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  19. <p>JSON data object of the node which will be moved.</p>
  20. <p class="highlight_red">Please ensure that this data object is an internal node data object in zTree.</p>
  21. <h4 class="topLine"><b>moveType</b><span>String</span></h4>
  22. <p>Moved to the target node's relative position.</p>
  23. <p class="highlight_red">"inner" means: to be taregetNode's child node.</p>
  24. <p class="highlight_red">"prev" means: to be taregetNode's previous sibling node.</p>
  25. <p class="highlight_red">"next" means: to be taregetNode's next sibling node.</p>
  26. <h4 class="topLine"><b>isSilent</b><span>Boolean</span></h4>
  27. <p>After move the node, whether to automatically expand its parent node.</p>
  28. <p>isSilent = true means: don't expand its parent node.</p>
  29. <p>isSilent = false or omit this parameter means: expand its parent node.</p>
  30. <h4 class="topLine"><b>Return </b><span>JSON</span></h4>
  31. <p>return the node which be moved, it is same as the 'treeNode' parameter.</p>
  32. <p class="highlight_red">Return null means: move node has failed. The cause:<br/>
  33. &nbsp;1. the targetNode is the treeNode's parent node, and moveType = "inner"<br/>
  34. &nbsp;2. the targetNode is the treeNode's child node.
  35. </p>
  36. </div>
  37. <h3>Examples of function</h3>
  38. <h4>1. Move the second root node to the first root node's child node.</h4>
  39. <pre xmlns=""><code>var treeObj = $.fn.zTree.getZTreeObj("tree");
  40. var nodes = treeObj.getNodes();
  41. treeObj.moveNode(nodes[0], nodes[1], "inner");
  42. </code></pre>
  43. <h4>2. Move the second root node to the first root node's previous sibling node.</h4>
  44. <pre xmlns=""><code>var treeObj = $.fn.zTree.getZTreeObj("tree");
  45. var nodes = treeObj.getNodes();
  46. treeObj.moveNode(nodes[0], nodes[1], "before");
  47. </code></pre>
  48. </div>
  49. </div>