EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on May 23, 2013, 03:31:53 AM



Title: tree - getting the breadcrumbs of a node
Post by: devnull 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





Title: Re: tree - getting the breadcrumbs of a node
Post by: stworthy 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)