Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Hongmin Ren on Mar 01, 2009 06:55
open dhtmlx forum
dhtmlxTree dynamic Destruction exception

Dear,

I use dhtmlXTree v1.3 in IE7. Because I need to reload new XMLs into the same tree, I destruct dhtmlxTree dynamically and encountered a strange exception: “self.parentObject.lastChild is null or is not an object” in dhtmlxTree_kn.js when I click anywhere in the Div to create the destructed tree after the dhtmlxtree is destructed.

My example code is as follow:

<div id="FacetTreeDiv" style="height:450px; width:600px; margin:0 0 0 4px;"></div>

<script type="text/javascript">
var facetTree=new dhtmlXTreeObject("FacetTreeDiv","100%","100%",2147483647);
facetTree.enableKeyboardNavigation(true);
facetTree.setImagePath("Imgs/");
facetTree.enableTreeLines(true);
facetTree.enableDragAndDrop(false);
facetTree.setImageArrays("plus","plus2.gif","plus3.gif","plus4.gif","plus.gif","plus5.gif");
facetTree.setImageArrays("minus","minus2.gif","minus3.gif","minus4.gif","minus.gif","minus5.gif");
facetTree.loadXMLString('<?xml version="1.0" encoding="utf-8" ?> <tree id="2147483647"><item text="TreeExample" id="2147483646" open="1" nocheckbox="1" im0="Template.gif" im1="Template.gif" im2="Template.gif"></item></tree>');

alert("Test To Destruct Tree !");
        
facetTree.destructor();
        
</script>

Then click anywhere in the FacetTreeDiv, an exception occurs:self.parentObject.lastChild is null or is not an object in dhtmlxTree_kn.js

Give me some help please!

Thanks!
Answer posted by Alex (support) on Mar 02, 2009 05:30

Hello, 

What approach do you use to reload the tree ?

The correct one is to delete all child items and then add necessary items:

tfacetTree.deleteChildItems(2147483647);

facetTree.loadXMLString('<?xml version="1.0" encoding="utf-8" ?><tree id="2147483647">.....</tree>');