EasyUI Forum
October 03, 2025, 06:37:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: tree - getting the breadcrumbs of a node  (Read 9787 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: May 23, 2013, 03:31:53 AM »

How can I get the breadcrumb IDs of a clicked node:

A
 - B
  - C
   - D

For example, if I select D, I would like to know the route back to the root: A,B,C,D

If I select B I would like to return: A,B



Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 23, 2013, 06:28:54 PM »

Loop the node up to root and the node's path can be retrieved.
Code:
var path = '';
var node = $('#tt').tree('getSelected');
while(node){
path = '/' + node.text + path;
node = $('#tt').tree('getParent', node.target);
}
console.log(path)
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!