setting.callback.beforeClick.html 2.5 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>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>Before click callback, return false to prevent the 'onClick' callback.</p>
  9. <p>Default: null</p>
  10. </div>
  11. </div>
  12. <h3>Function Parameter Descriptions</h3>
  13. <div class="desc">
  14. <h4><b>treeId</b><span>String</span></h4>
  15. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  16. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  17. <p>JSON data object of the node which is clicked</p>
  18. <h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
  19. <p>Node is selected or deselected state, please see table below for details</p>
  20. <table width="100%" border="0" cellspacing="1" cellpadding="0">
  21. <thead><tr><td>clickFlag</td><td title="Whether to allow multi-select">selectedMulti</td><td title="Whether to press Ctrl-key or Cmd-key">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="Node's selection state">isSelected</td><td>operate for selected</td></tr></thead>
  22. <tbody>
  23. <tr><td>1</td><td>true</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
  24. <tr><td>1</td><td>true</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
  25. <tr><td>2</td><td>true</td><td>true</td><td>false</td><td>node is selected (multi)</td></tr>
  26. <tr><td>0</td><td>true</td><td>true</td><td>true</td><td>node is deselected</td></tr>
  27. <tr><td>1</td><td>false</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
  28. <tr><td>1</td><td>false</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
  29. <tr><td>1</td><td>false</td><td>true</td><td>false</td><td>node is selected (single)</td></tr>
  30. <tr><td>0</td><td>false</td><td>true</td><td>true</td><td>node is deselected</td></tr>
  31. </tbody>
  32. </table>
  33. <h4 class="topLine"><b>Return </b><span>Boolean</span></h4>
  34. <p>return true or false</p>
  35. <p class="highlight_red">If return false, zTree will not change selected state, and will not trigger the 'onClick' callback.</p>
  36. </div>
  37. <h3>Examples of setting & function</h3>
  38. <h4>1. disabled to click the node</h4>
  39. <pre xmlns=""><code>function myBeforeClick(treeId, treeNode, clickFlag) {
  40. return (treeNode.id !== 1);
  41. };
  42. var setting = {
  43. callback: {
  44. beforeClick: myBeforeClick
  45. }
  46. };
  47. ......</code></pre>
  48. </div>
  49. </div>