Categories | Question details Back To List | ||
problem with openAllItemsDynamic Hi, I use dynamic tree to navigate on the structure, and I need to copy some items after checkbox is checked. If I check a branch with children, it does not load any children, so I can't copy them. I tried to use openAllItemsDynamic and openAllItems on onCheck and onBeforeCheck events, but in both cases I have some problems. With openAllItems it opens only one level below, and with openAllItemsDynamic, there are two (or more) same AJAX calls (with same ID and UID) - in the result, I get multiplied all children. Also, items checked before openAllItemsDynamic call are unchecked. I use the dhtmlxSuite_2008Rel3_pro version with code like this: tree=new dhtmlXTreeObject('treeBox',"100%","100%",0); tree.enableThreeStateCheckboxes(true); tree.enableCheckBoxes(true, false); tree.enableLoadingItem('Loading...'); tree.setXMLAutoLoading("/get_xml_tree.php"); tree.loadXML("get_xml_tree.php?id=1"); tree.attachEvent("onBeforeCheck", BeforeCheckItem); function BeforeCheckItem(id, state) { tree.openAllItemsDynamic(id); return true; } There is a second problem, probably related. Sometimes when I call openAllItemsDynamic on the big structure, I get occasionaly JS error: 'that.G_node.id' is null or not an object. It appears to be a random error, so I believe it's related to asynchronous AJAX calls. Answer posted by Support on Feb 02, 2009 03:08 >>and with openAllItemsDynamic, there are two (or more) same AJAX calls (with same ID and UID) Please be sure that each element in Tree has unique ID. While testing locally - issue can't be reconstructed ( each branch loaded only once ) Beware that even if sub-elements loaded correctly, they will not be checked according to the state of parent element , because data loading is async. process and elements will be loaded some time after the state of parent element changed. >> It appears to be a random error, so I believe it's related to asynchronous AJAX calls. updated dhtmlxtree_xw.js sent by email, please try to use it instead of original one. Answer posted on Feb 02, 2009 04:17 updated dhtmlxtree_xw.js sent by email, please try to use it instead of original one Sorry, but the mentioned file not arrived. Can you send it again or provide me a link to updated version? Please be sure that each element in Tree has unique ID. Yes, all IDs are unique. While testing locally - issue can't be reconstructed ( each branch loaded only once ) I'll try to make a simple example for you with that problem. Beware that even if sub-elements loaded correctly, they will not be checked according to the state of parent element , because data loading is async. process and elements will be loaded some time after the state of parent element changed. Is there any event or other way to launch the code after ALL async calls are finished? Just after all the sub, sub, sub... items are loaded. Answer posted by Support on Feb 02, 2009 05:19 >>Is there any event or other way to launch the code after ALL async calls are finished? Just after all the sub, sub, sub... items are loaded. While it not a part of public API, there is a onAllOpenDynamic event which fire when openAllDynamic finish loading of all possible data. Answer posted on Feb 02, 2009 06:20 Even with sent hotfix, I get an error: that.G_node is null in window.setTimeout( funct...hat._loadDynXML(that.G_node.id); },100); To see my test case, check the page http://pff.mediaskop.pl/test/test3.php Test procedure to see double AJAX request: 1 - expand MEDIASKOP 2 - expand DLA STUDIA 3 - mark (not checkbox, just click the name) item with children 4 - hit one of the test button 4a - after hit of the openAllItemsDynamic button, you get two same AJAX calls resulting in doubled children items - each name under each parent have to be unique 4b - after hit of the openAllItems button, you get result as expected, because there are no subitems Test procedure to see above mentioned problem with "that.G_node is null" is just to click openAllItemsDynamic with DLA STUDIA selected (needs reload since tree caches AJAX results). All subitems (till the error) will open, but with multiplied items. Result not expected. Click the openAllItems button, and there will be only one AJAX call, but no subitems also. Result not expected. I hope it's enough to debug the problem. Thanks Answer posted on Feb 02, 2009 08:15 Ok, i found a bug. It seems, that after enableLoadingItem call, openAllItemsDynamic do not works properly. It's not critical for us to use it, but it would be nice to fix it for a next release (or maybe another hotfix?) Answer posted on Feb 09, 2009 05:23 Thank you for a patch. Now it works as expected. |