Treegrid: save and restore expanded/closed nodes state

I have treegrid. Let us say I have 6 nodes. When I am using it, I have 5 closed nodes and one expanded node. When grid data refreshes I want the tree grid to display with same 5 nodes closed and 1 node expanded.

Any way or suggestion on how to do it?

You can save treeGrid open state in cookies. Please check more information here docs.dhtmlx.com/doku.php?id=dhtm … pulation&s[]=saveOpenStates

This only really works if your NOT dynamically loading the data. Otherwise you may need to call the load function a few times when each level is loaded, as the node to open doesnt exist yet.

To check the loading state use
mygrid.attachEvent(“onXLS”, function(grid_obj){
// your code here
});
mygrid.attachEvent(“onXLE”, function(grid_obj,count){
// your code here
});

It is not working for me. Cookie is being saved but open state is not being shown after tree reloads.
I am using DHTMLX Layout and drag n drop.

I have

 treegrid.attachEvent("onOpenEnd", function(id,state){
     treegrid.saveOpenStates('openstate');
 });

treegrid.loadXML(“xml/treenohead/”, postRefreshTree);

function postRefreshTree() {
treegrid.loadOpenStates(‘openstate’);
//other stuff
}

Be sure that "treegrid.attachEvent(“onOpenEnd” is called AFTER loadOpenStates, or it can overwrite previosly saved list of open items.

My treegrid is attached to dhtmlxLayout. I am loading via XML including header and I am have tried returning open=“0” and open=“1” and without open attribute but to no success.

There is another dhtmlxgrid on this layout. It is a regular grid and not tree grid.

Any known issues in using it with Layout. here is the code

treegrid = dhxLayout.cells("b").attachGrid();
treegrid.setImagePath("/media/dhtmlx/dhtmlxGrid/codebase/imgs/");
treegrid.init();

treegrid.enableAutoSizeSaving();
treegrid.enableSortingSaving();
treegrid.loadXML("/xml/tree/", postRefreshTree);
dhtmlxError.catchError("LoadXML",function(a,b,data){});

treegrid.enableCollSpan(true);
treegrid.enableDragAndDrop(true);
treegrid.enableTreeCellEdit(false);

 treegrid.attachEvent("onOpenEnd", function(id,state){
     treegrid.saveOpenStates();
    // treegrid.setSizes();
 });
 
 treegrid.attachEvent("onResizeEnd", function(obj){

    treegrid.saveSizeToCookie();
    //treegrid.setSizes();

 });

 treegrid.attachEvent("onAfterSorting", function(index,type,direction){
    treegrid.saveSortingToCookie();
//    treegrid.setSizes();
 });

function postRefreshTree() {
treegrid.loadSizeFromCookie();
treegrid.loadSortingFromCookie();
treegrid.loadOpenStates();
//other stuff
}

This issue confirmed and will be fixed at the next version of dhtmlxGrid

When is the next release?
Can we get a patch sooner?

To get patch sooner please open ticket at support.dhtmlx.com/

Hi,

I’m running version v.3.0 build 110707 Pro. Should I also open a case to get this patch, or will it be posted on the forum?

Thanks
-Gabriel