setting.callback.onDrop.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(event, treeId, treeNodes, targetNode, moveType, isCopy)</span><span class="path">setting.callback.</span>onDrop
  4. </h2>
  5. <h3>Overview<span class="h3_info">[ depends on <span
  6. class="highlight_green">jquery.ztree.exedit</span> js ]</span></h3>
  7. <div class="desc">
  8. <p></p>
  9. <div class="longdesc">
  10. <p>Used to capture the drop event when drag-drop node.</p>
  11. <p class="highlight_red">If you set 'setting.callback.beforeDrop',and return false, zTree will restore
  12. the dragged nodes, and will not trigger the 'onDrop' callback.</p>
  13. <p>Default: null</p>
  14. </div>
  15. </div>
  16. <h3>Function Parameter Descriptions</h3>
  17. <div class="desc">
  18. <h4><b>event</b><span>js event Object</span></h4>
  19. <p>event Object</p>
  20. <h4 class="topLine"><b>treeId</b><span>String</span></h4>
  21. <p>zTree unique identifier: <b class="highlight_red">treeId</b>, the id of the containing tree.</p>
  22. <h4 class="topLine"><b>treeNodes</b><span>Array(JSON)</span></h4>
  23. <p>A collection of the nodes which has been dragged</p>
  24. <p class="highlight_red">The treeNodes are the data of the nodes which be dragged, when move nodes.</p>
  25. <p class="highlight_red">The treeNodes are the clone data of the nodes which be dragged, when copy
  26. nodes.</p>
  27. <h4 class="topLine"><b>targetNode</b><span>JSON</span></h4>
  28. <p>JSON data object of the target node which treeNodes are drag-dropped.</p>
  29. <p class="highlight_red">If the treeNodes will be root node, the targetNode = null</p>
  30. <h4 class="topLine"><b>moveType</b><span>String</span></h4>
  31. <p>the relative position of move to the target node</p>
  32. <p class="highlight_red">"inner": will be child of targetNode</p>
  33. <p class="highlight_red">"prev": will be sibling node, and be in front of targetNode</p>
  34. <p class="highlight_red">"next": will be sibling node, and be behind targetNode</p>
  35. <p class="highlight_red">If moveType is null, means drag & drop is cancel.</p>
  36. <h4 class="topLine"><b>isCopy</b><span>Boolean</span></h4>
  37. <p>the flag used to judge copy node or move node</p>
  38. <p class="highlight_red">true: copy node; false: move node</p>
  39. </div>
  40. <h3>Examples of setting & function</h3>
  41. <h4>1. When drag-drop nodes complete, alert the number of dragged nodes and info about targetNode.</h4>
  42. <pre xmlns=""><code>function myOnDrop(event, treeId, treeNodes, targetNode, moveType) {
  43. alert(treeNodes.length + "," + (targetNode ? (targetNode.tId + ", " + targetNode.name) : "isRoot" ));
  44. };
  45. var setting = {
  46. callback: {
  47. onDrop: myOnDrop
  48. }
  49. };
  50. ......</code></pre>
  51. </div>
  52. </div>