Title: getting the root node [Solved] Post by: devnull on May 16, 2014, 08:30:24 PM I am trying to get the top parent from a child node, however the getRoot() always returns the very first root and not the root of the child:
if I call getRoot() from a 'usercopy' node, then the root returned is the 'user' node and not the 'usercopy' node. How can I get the correct root node ? Code:
Title: Re: getting the root node Post by: stworthy on May 16, 2014, 10:21:56 PM The 'getRoot' method returns the first top root. To get all the root nodes, please try 'getRoots' method.
Code: var roots = $('#tt').tree('getRoots'); Title: Re: getting the root node Post by: devnull on May 16, 2014, 11:32:37 PM Thanks, but I don't want to get all of the roots, I just want to get the top parent of the selected node.
In the previous json code there are 2 nodes: 1) user 2) usercopy - Child 1 -- Child 1 A --- Child 1 A A - Child 2 I want to be able to get the "usercopy" node from any of the Children below it. For example, when [Child 1 A A] or [Child 1] or [Child 2] is clicked, I want to get the [usercopy] node. Thanks Title: Re: getting the root node Post by: stworthy on May 17, 2014, 12:40:49 AM Please try to override the 'getRoot' method as below:
Code: $.extend($.fn.tree.methods, { Title: Re: getting the root node [Solved] Post by: devnull on May 17, 2014, 01:17:58 AM Thanks, yes that works.
Can this be added as a standard method ?? Title: Re: getting the root node [Solved] Post by: stworthy on May 17, 2014, 02:01:39 AM Yes, this enhanced function will be integrated into next version. You can download the patch file(for version 1.3.6) from http://www.jeasyui.com/download/downloads/jquery-easyui-1.3.6-patch.zip, which has integrated this function.
|