setting.callback.onClick.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(event, treeId, treeNode, clickFlag)</span><span class="path">setting.callback.</span>onClick</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>Used to capture the click event when click node.</p>
  9. <p class="highlight_red">If you set 'setting.callback.beforeClick',and return false, zTree will not change selected state, and will not trigger the 'onClick' callback.</p>
  10. <p>Default: null</p>
  11. </div>
  12. </div>
  13. <h3>Function Parameter Descriptions</h3>
  14. <div class="desc">
  15. <h4><b>event</b><span>js event Object</span></h4>
  16. <p>event Object</p>
  17. <h4 class="topLine"><b>treeId</b><span>String</span></h4>
  18. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  19. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  20. <p>JSON data object of the node which is clicked</p>
  21. <h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
  22. <p>Node is selected or deselected state, please see table below for details</p>
  23. <table width="100%" border="0" cellspacing="1" cellpadding="0">
  24. <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>
  25. <tbody>
  26. <tr><td>1</td><td>true</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
  27. <tr><td>1</td><td>true</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
  28. <tr><td>2</td><td>true</td><td>true</td><td>false</td><td>node is selected (multi)</td></tr>
  29. <tr><td>0</td><td>true</td><td>true</td><td>true</td><td>node is deselected</td></tr>
  30. <tr><td>1</td><td>false</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
  31. <tr><td>1</td><td>false</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
  32. <tr><td>1</td><td>false</td><td>true</td><td>false</td><td>node is selected (single)</td></tr>
  33. <tr><td>0</td><td>false</td><td>true</td><td>true</td><td>node is deselected</td></tr>
  34. </tbody>
  35. </table>
  36. </div>
  37. <h3>Examples of setting & function</h3>
  38. <h4>1. When click node, alert info about 'tId' and 'name'.</h4>
  39. <pre xmlns=""><code>function myOnClick(event, treeId, treeNode) {
  40. alert(treeNode.tId + ", " + treeNode.name);
  41. };
  42. var setting = {
  43. callback: {
  44. onClick: myOnClick
  45. }
  46. };
  47. ......</code></pre>
  48. </div>
  49. </div>