Find Tree Node

Sep 20, 2012 at 2:41 PM


Is there any way to find tree node by it's node value, means I have my object which contain Id which is bind to tree. Now I want to find node by Id and make it selected.

Please help me out.





Sep 21, 2012 at 2:30 AM

In the html node where you store the id(probably an hidden field?) add a Css class say idContainer. Then you can get the node with a given id with something like:

$(".idContainer[value='1111213']") where 1111213 is the id you are looking for. This way you get the  hidden filed containing the id. Once you get the hidden filed with the id you need you can go to the root of each node by putting a css class in the container of each node ( it should be a span or a div), say treeNode.

Now with: $(".idContainer[value='1111213']").closest(".treeNode")

Now suppose that uìyou want to go to the url contained in link that is in the node you can take its href with:

$(".idContainer[value='1111213']").closest(".treeNode").find("a").href.......and so on. I hope you got the you can adapt it to your case.