setting.callback.beforeDrag.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNodes)</span><span class="path">setting.callback.</span>beforeDrag</h2>
  4. <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.exedit</span> 扩展 js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>用于捕获节点被拖拽之前的事件回调函数,并且根据返回值确定是否允许开启拖拽操作</p>
  9. <p>默认值:null</p>
  10. </div>
  11. </div>
  12. <h3>Function 参数说明</h3>
  13. <div class="desc">
  14. <h4><b>treeId</b><span>String</span></h4>
  15. <p>被拖拽的节点 treeNodes 所在 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
  16. <h4 class="topLine"><b>treeNodes</b><span>Array(JSON)</span></h4>
  17. <p>要被拖拽的节点 JSON 数据集合</p>
  18. <p class="highlight_red">v3.x 允许多个同级节点同时被拖拽,因此将此参数修改为 Array(JSON)</p>
  19. <p class="highlight_red">如果拖拽时多个被选择的节点不是同级关系,则只能拖拽鼠标当前所在位置的节点</p>
  20. <h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
  21. <p>返回值是 true / false</p>
  22. <p class="highlight_red">如果返回 false,zTree 将终止拖拽,也无法触发 onDrag / beforeDrop / onDrop 事件回调函数</p>
  23. </div>
  24. <h3>setting & function 举例</h3>
  25. <h4>1. 禁止全部拖拽操作</h4>
  26. <pre xmlns=""><code>function zTreeBeforeDrag(treeId, treeNodes) {
  27. return false;
  28. };
  29. var setting = {
  30. edit: {
  31. enable: true
  32. },
  33. callback: {
  34. beforeDrag: zTreeBeforeDrag
  35. }
  36. };
  37. ......</code></pre>
  38. </div>
  39. </div>