Tree state - Line 1965 'tree' is null or not an object

When I try to save the tree state with “sample 1”, the code works fine. However, when I try to save the tree state with “sample 2” code I get the following error “Line 1965 ‘tree’ is null or not an object”.



The only difference in the two sample is that in sample 2 I name the tree object oTreeMenus instead of tree.



Question 1 - Does the tree object always have to be named “tree”?



Question 2 - If so how is it possible for me to with more than one tree on a page?



Question 3 - The way I currently am going about placing multiple tree controls on a page is to declare 2 global variables oTree1, oTree2 and then I can get a handle on those objects later when I submit the page, but if I always have to name my tree objects “tree”, what is the best way to get a handle on those items later when I want to submit the page?



This only became an issue when I tried using loadOpenStates() function. Prior to that I was always able to name my tree object whatever I wanted.



-------------

Sample 1

-------------

tree = new dhtmlXTreeObject(“divMenuTree”,“100%”,“100%”,0);

tree.setImagePath(“…/…/DHTMLXSuite/imgs/”);

tree.enableCheckBoxes(1);

tree.enableThreeStateCheckboxes(true);

tree.loadXML(“…/BusinessLogic/BL_DHTMLXDataProcessor.php?caller=P_RolePrivileges&action=getMenus&roleId=” + roleId, function(){tree.loadOpenStates()});

tree.attachEvent(“onOpenEnd”,function(){

tree.saveOpenStates();

});



-------------

Sample 2

-------------

oTreeMenus = new dhtmlXTreeObject(“divMenuTree”,“100%”,“100%”,0);

oTreeMenus.setImagePath(“…/…/DHTMLXSuite/imgs/”);

oTreeMenus.enableCheckBoxes(1);

oTreeMenus.enableThreeStateCheckboxes(true);

oTreeMenus.loadXML(“…/BusinessLogic/BL_DHTMLXDataProcessor.php?caller=P_RolePrivileges&action=getMenus&roleId=” + roleId, function(){oTreeMenus.loadOpenStates()});

oTreeMenus.attachEvent(“onOpenEnd”,function(){

oTreeMenus.saveOpenStates();

});

There was a bug in original release , which cause problem with state saving, when tree object named differently.
The issue already fixed in latest build
support@dhtmlx.com we will provide a separate fix.


Ok.  I downloaded and installed the newest bug fixes.  The error is no longer present.  However, when I place two trees on the same page, the folder tree states seem to be mutually exclusive now.  When I click on oTreeMenus and oTreeDocLib, it only saves the state of the last tree I click on.



example 1 - click on oTreeMenus and submit -> it will save state of oTreeMenu



example 2 - click on oTreeDocLib and submit -> it will save state of oTreeDocLib



example 3 - first click on oTreeMenus and then click on oTreeDocLib -> only oTreeDocLib state is saved



example 4 - first click o oTreeDocLib and then click on oTreeMenus -> only oTreeMenus state is saved



 



/
* @desc Initialize the dhtmlxTree for menus tab
*/
function initializeMenuTree()

    oTreeMenus = new dhtmlXTreeObject(“divMenuTree”,“100%”,“100%”,0);
    oTreeMenus.setImagePath("…/…/DHTMLXSuite/imgs/");
    oTreeMenus.enableCheckBoxes(1);
    oTreeMenus.enableThreeStateCheckboxes(true);
    oTreeMenus.enableTreeImages(false);
    oTreeMenus.loadXML("…/BusinessLogic/BL_DHTMLXDataProcessor.php?caller=P_RolePrivileges&action=getMenus&roleId=" + roleId, function(){oTreeMenus.loadOpenStates()});
    oTreeMenus.attachEvent(“onOpenEnd”,function(){
    oTreeMenus.saveOpenStates();
    });
}



/

* @desc Initialize the dhtmlxTree for document library folder tab
*/
function initializeDocumentLibraryFolderTree()
{
    oTreeDocLib = new dhtmlXTreeObject(“divDocumentLibraryFolderTree”,“100%”,“100%”,0);
    oTreeDocLib.setImagePath("…/…/DHTMLXSuite/imgs/");
    oTreeDocLib.enableCheckBoxes(1);
    oTreeDocLib.enableThreeStateCheckboxes(true);
    oTreeDocLib.loadXML("…/BusinessLogic/BL_DHTMLXDataProcessor.php?caller=P_RolePrivileges&action=getDocLibFolders&roleId=" + roleId, function(){oTreeDocLib.loadOpenStates()});
    oTreeDocLib.attachEvent(“onOpenEnd”,function(){
    oTreeDocLib.saveOpenStates();
    });
}

Has this been confirmed?

Both - saveOpenStates and loadOpenStates allow to provide a name of saving as parameter, if you want to save setting for different tree, you need to use those commands with different names, in other case settings will be overwritten.

Thank you.  That worked.