zTreeObj.getNodeIndex.html 1.2 KB

123456789101112131415161718192021222324252627282930
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeNode)</span><span class="path">zTreeObj.</span>getNodeIndex</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>Get the node's index in the same level nodes. (start from 0)</p>
  9. <p class="highlight_red">Please use zTree object to executing the method.</p>
  10. </div>
  11. </div>
  12. <h3>Function Parameter Descriptions</h3>
  13. <div class="desc">
  14. <h4><b>treeNode</b><span>JSON</span></h4>
  15. <p>JSON data object of the node which need to get index.</p>
  16. <p class="highlight_red">Please ensure that this data object is an internal node data object in zTree.</p>
  17. <h4 class="topLine"><b>Return </b><span>Number</span></h4>
  18. <p class="highlight_red">return the index. (start from 0)</p>
  19. <p class="highlight_red">If there is no this node, return -1.</p>
  20. </div>
  21. <h3>Examples of function</h3>
  22. <h4>1. Get the first selected node's index in the same level nodes.</h4>
  23. <pre xmlns=""><code>var treeObj = $.fn.zTree.getZTreeObj("tree");
  24. var nodes = treeObj.getSelectedNodes();
  25. if (nodes.length>0) {
  26. var index = treeObj.getNodeIndex(nodes[0]);
  27. }
  28. </code></pre>
  29. </div>
  30. </div>