how to get the list of node parent parent … root until the final parent (root) is reached?
i.e. node, nodeparent, nodeparentparent,…root
Is there any method like getPreProcessingNodes() or postProcessingNOdes()
I have tried this way…need help regarding
var parentids;
function getListOfParentIds(id,accesslevelids)
{
var parentid=tree.getParentId(id);
accesslevelids=parentid+","+accesslevelids;
if(parentid!=“0”)
getListOfParentIds(parentid,accesslevelids);
else
parentids=accesslevelids;
//return “”+accesslevelids;
}
Actually when i try to return value in else part , it is giving undefined (since the loop is not yet finished, when the result has come)
So, i have taken it in a separate variable “accesslevel”.
I need the function itself returning the result, ratherthan taken separately ina variable.
Try the following approach:
function getParents(id){
if(id==0){
parents[parents.length] = tree.getParentId(id);
getParents(parents[parents.length-1])
return parents;
}
}