How could i get the first node of a tree

i’ve got a xml tree,the follow is the xml:

<?xml version='1.0' encoding='UTF-8'?>

during the former edition i got the method : but it doesn’t work on the edition 3.0
dhtmlXTreeObject.prototype.getFirstNodeId =function()
var tempId = this.rootId;
var temp=this._globalIdStorageFind(tempId);
if(temp)return temp.childNodes[0].id;
else return “”;

who can help me thanks a lot

1 Like

and i am using ie9 and firefox 10.X

If you gave such simple Tree & you know its structure, use method ‘getItemIdByIndex(itemId,index)’

var tempId = this.rootId; var id = tree.getItemIdByIndex(tempId ,0);

Here is description: … midbyindex

thanks a lot but i’ve got null the follow is my code

function itemOnclick(id){
var url = “openUserWorkList.action?”+id;
function treeInit(){
tree=new dhtmlXTreeObject(“treeboxbox_tree”,“100%”,“100%”,0);
var date = new Date();
var tempId = tree.rootId;
var id = tree.getItemIdByIndex(tempId ,0);


You need to issue your getting of ID in a function :

function gettingID(){ var tempId = tree.rootId; var id = tree.getItemIdByIndex(tempId ,0); alert(id); }

And put it as the second parameter in loadXML() method:

tree.loadXML("workDiaryProjectTreeXML.action", gettingID);

In the other you can not get an item by its id as the item is not loaded yet.