setting.callback.beforeClick.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode, clickFlag)</span><span class="path">setting.callback.</span>beforeClick</h2>
  4. <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</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>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
  16. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  17. <p>被单击的节点 JSON 数据对象</p>
  18. <h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
  19. <p>节点被点击后的选中操作类型,详细看下表</p>
  20. <table width="100%" border="0" cellspacing="1" cellpadding="0">
  21. <thead><tr><td>clickFlag</td><td title="是否允许多点选中">selectedMulti</td><td title="是否按下 Ctrl 或 Cmd 键">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="节点当前选择状态">isSelected</td><td>选中操作</td></tr></thead>
  22. <tbody>
  23. <tr><td>1</td><td>true</td><td>false</td><td>false</td><td>普通选中</td></tr>
  24. <tr><td>1</td><td>true</td><td>false</td><td>true</td><td>普通选中</td></tr>
  25. <tr><td>2</td><td>true</td><td>true</td><td>false</td><td>追加选中</td></tr>
  26. <tr><td>0</td><td>true</td><td>true</td><td>true</td><td>取消选中</td></tr>
  27. <tr><td>1</td><td>false</td><td>false</td><td>false</td><td>普通选中</td></tr>
  28. <tr><td>1</td><td>false</td><td>false</td><td>true</td><td>普通选中</td></tr>
  29. <tr><td>1</td><td>false</td><td>true</td><td>false</td><td>普通选中</td></tr>
  30. <tr><td>0</td><td>false</td><td>true</td><td>true</td><td>取消选中</td></tr>
  31. </tbody>
  32. </table>
  33. <h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
  34. <p>返回值是 true / false</p>
  35. <p class="highlight_red">如果返回 false,zTree 将不会选中节点,也无法触发 onClick 事件回调函数</p>
  36. </div>
  37. <h3>setting & function 举例</h3>
  38. <h4>1. 禁止节点被选中</h4>
  39. <pre xmlns=""><code>function zTreeBeforeClick(treeId, treeNode, clickFlag) {
  40. return (treeNode.id !== 1);
  41. };
  42. var setting = {
  43. callback: {
  44. beforeClick: zTreeBeforeClick
  45. }
  46. };
  47. ......</code></pre>
  48. </div>
  49. </div>