Get sub items of unexpanded node

I am using a dhtmlxTreeGrid.



I have a parent tree node which is not yet expanded but I want to get the id of all the child items on that unexpanded parent node. Is there a simple solution to this scenario?



I have tried getSubItems() and getAllSubItems() but to no avail.



Thanks in advance!


You can use next code snippet


function get_ids(id){
var els=[];
mygrid._h2.forEachChild(id,function(el){
els.push(el.id)
})
return els.join(",")
}



I tried the code snippet above and it will still not get the subitems / subchilds of an unexpanded node.

Here is how I load the treegrid:

grid = new dhtmlXGridObject(‘gridbox’);
grid.selMultiRows = true;
grid.imgURL = “…/…/…/dhtmlxGrid/codebase/imgs/icons_greenfolders/”;
grid.setHeader(“Data Room Index,V,M,P,S,T”);
grid.setInitWidths("*,40,40,40,40,40");
grid.setColAlign(“left,center,center,center,center,center”);
grid.setColTypes(“tree,img,img,img,img,img”);
grid.enableTooltips(“true,false,false,false,false,false”);
grid.enableSmartXMLParsing(true);
grid.setSkin(“light”);
grid.enableTreeCellEdit(false);
grid.init();                   
grid.setOnRowSelectHandler(doProcessItem);            
grid.loadXML(“treegridsamplelarge.xml”);


function doProcessItemState(id,col){
        get_ids(id);
}

function get_ids(id){

        var els=[];

        mygrid._h2.forEachChild(id,function(el){

               alert(el.id);             //supposed to display every child of the unexpanded node.

              els.push(el.id)

        })

      return els.join(",")
}

It works perfectly if the node was previously expanded the first time.
I am currently using v.1.5 build 80319 evaluation version.

Thanks!

I am currently using v.1.5 build 80319 evaluation version.
The code snippet was provided for dhtmlxtreegrid 1.6

In case of dhtmlxgrid 1.5 it will work only if smartXMLParsing disabled.
The TreeGrid 1.5 can’t provide info about ID’s in not-parsed. branches, while they are not processed.
It can be done as
    treegrid._reParse(treegrid.getRowById(ID));
    alert(treegrid.getAllSubItems(ID))

but such approach may slow down grid rendering.

Thanks for the reply.

If I have the 1.6 version, will it work if smartXMLParsing is not disabled?

Yes, it work in both cases - with or without smartXMLParsing mode enabled.
( while it will provides access to elements IDs , row specific API calls still require row parsing and as result will cause decrease of performance, if you plan to call some functionality against big amount of rows  )